0

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!

5
Contributors
7
Replies
13
Views
6 Years
Discussion Span
Last Post by ahmadmomi
0

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
0

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?

0

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 ..

0

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?????????????????????????????????

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.