Greeting to all! Thank in advanced for help

I wanted to retrieve a value in text area using javascript
and store it into s variable so that i can pass the variable as parameter
for AJAX purpose.

This might be a stupid question.... and i'm sorry about that~
besides, thank a lot for help!

I can say it how its done using jquery:

var text = $('textarea').val();

You can give an unique id to your text area.

<textarea id="mytext"></textarea>

You can easily get in javascript

var myText = document.getElementById("myText");
var s = myText.value; // This will now contain text of textarea

Thank you for help ^______^

Problem Solved! but one more problem comes again:
This is my code:

<script type="text/javascript">
function ShowRecord(tID,comment)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("Table1").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ReplyAJAX.php?TabID="+tID+"replycomment="+comment,true);
xmlhttp.send();
}
</script>

i want to pass 2 variable as parameter after user press Reply button!

<input type="hidden" name="TabID" value="<?php echo $tabID; ?>"/><p>
Comment : 
<br /><textarea rows="5" cols="80" name="replycomment" id="Comment"></textarea>

<script language="javascript">
var myText = document.getElementById("Comment");
var s = myText.value;
</script>
<p><input type="button" name="btnReply" value="Reply" onClick="ShowRecord(<?php echo $tabID; ?>,s)"/>

did i wrote it correctly?

Nop,here is the problem

In your code line 19 of first Code Snippet

xmlhttp.open("GET","ReplyAJAX.php?TabID="+tID+"replycomment="+comment,true);

Change it into

xmlhttp.open("GET","ReplyAJAX.php?TabID="+tID+"&replycomment="+comment,true);


You forgot an Ampersand symbol (&) . :)

Hope it helps ..

^__^''
Oh Yeah!
Thank you~ Problem solve!

I used two pages one is html and another php .I want to display html text area content in php.<?php $text=$_REQUEST["textarea name"];echo str_replace("\n","<br />",$text);?>.It shown good result when I executed through htmlpage.But If I directly open php page its show error.what is problem?????????????????????????????????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.