Avocado Posted March 2, 2010 Share Posted March 2, 2010 My html form: <body> <form> <p>Enter a sentence:</p> <textarea rows="3" cols="20" name="nameoftextarea"> </textarea> <input type="button" value="Send Sentence" onclick="getServerText()"> </form> <div id="myPageElement"> Sentence will show here </div> </body> getServerText is the function for sending the XMLHTTPRequest object. <head> <script Language="JavaScript"> function getXMLHTTPRequest() { try { req = new XMLHttpRequest(); } catch(err1) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err3) { req = false; } } } return req; } var http = getXMLHTTPRequest(); function getServerText() { var myurl = 'phppage.php'; myRand = parseInt(Math.random()*999999999999999); var modurl = myurl+"?rand="+myRand; http.open("GET", modurl, true); http.onreadystatechange = useHttpResponse; http.send(null); } function useHttpResponse() { if (http.readyState == 4) { if(http.status == 200) { var mytext = http.responseText; document.getElementById('myPageElement').innerHTML = mytext; } } else { document. getElementById('myPageElement').innerHTML = ""; } } </script> </head> The the $_GET["nameoftextarea"] on the php page doesn't display in <div> but the "Hi" does <html> <body> Hi <?php echo $_GET["nameoftextarea"];?> </body> </html> I just started php and I don't see where the error is, thanks. Link to comment https://forums.phpfreaks.com/topic/193878-echo-not-working/ Share on other sites More sharing options...
jl5501 Posted March 2, 2010 Share Posted March 2, 2010 you are not sending the textarea value anywhere, just your rand variable Link to comment https://forums.phpfreaks.com/topic/193878-echo-not-working/#findComment-1020339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.