thenewperson Posted November 2, 2009 Share Posted November 2, 2009 Trying to have words come out from php file but extremely knew to this and havnt a clue. Just trying to echo out javascript in field txtHint from the php file after the button is clicked html page <html> <head> <script type="text/javascript" src="clienthint.js"></script> </head> <body> <form> First Name: <input type="button" id="txt1" onclick="sub()" /> </form> <div id="txtHint"></div><p><a href="http://www.w3schools.com"> <img border="0" alt="Visit W3Schools!" src="b_pink.png" id="b1" /></a></p> </body> </html> clienthint.js var xmlhttp function sub(){ xmlhttp=GetXmlHttpObject(); var url="gethint.php"; url=url+"?q="; url=url+"&sid="+Math.random(); xmlhttp.open("GET",url,true); xmlhttp.send(null); } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } gethint.php <?php echo "<script type=\"text/javascript\"> function changeText(){ document.getElementById('txtHint').innerHTML = 'jimmy jones'; } </script> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179902-solved-lookin-for-easy-ajax-help/ Share on other sites More sharing options...
ngreenwood6 Posted November 3, 2009 Share Posted November 3, 2009 I might be overlooking something but by simply looking at your code it looks like you created the function but never called it. Try this: <?php echo "<script type=\"text/javascript\"> function changeText(){ document.getElementById('txtHint').innerHTML = 'jimmy jones'; } changeText(); </script> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179902-solved-lookin-for-easy-ajax-help/#findComment-949958 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.