thenewperson Posted November 1, 2009 Share Posted November 1, 2009 Trying to make image roll over using ajax just for test. Extremely new to this so be easy on me. Dont want the image roll over effect till i click submit if thats possible. But the rollover doenst work after pressing submit. html page <html> <head> <script type="text/javascript" src="clienthint.js"></script> </head> <body> <form> First Name: <input type="submit" id="txt1" onsubmit="sub()" /> </form> <span id="txtHint"><p><a href="http://www.w3schools.com" target="_blank"> <img border="0" alt="Visit W3Schools!" src="b_pink.png" id="b1" onmouseover="mouseOver()" onmouseout="mouseOut()" /></a></span></p> </body> </html> clienthint.js page var xmlhttp function sub(){ var url="gethint.php"; url=url+"?q="+str; } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } 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 $q=$_GET["q"]; echo "<script type=\"text/javascript\"> function mouseOver() { document.getElementById(\"b1\").src =\"b_blue.gif\"; } function mouseOut() { document.getElementById(\"b1\").src =\"b_pink.gif\"; } </script>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/179881-help-with-simple-ajax/ Share on other sites More sharing options...
bubbasheeko Posted November 2, 2009 Share Posted November 2, 2009 This really wouldn't be a rollover, but more of an image replace. I am not sure what is happening when you submit. You show a function being called, sub(). I don't see that in the code provided. Quote Link to comment https://forums.phpfreaks.com/topic/179881-help-with-simple-ajax/#findComment-948997 Share on other sites More sharing options...
mikesta707 Posted November 2, 2009 Share Posted November 2, 2009 you know we have an AJAX forums here right? Quote Link to comment https://forums.phpfreaks.com/topic/179881-help-with-simple-ajax/#findComment-948998 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.