tyra Posted March 1, 2010 Share Posted March 1, 2010 How to submit multiple forms with onchange event ? the goal is php to load them to various varibles. here is javascript.js var AJAXForms = false; var LastField = null; var isIE = false; // on !IE we only have to initialize it once if (window.XMLHttpRequest) { AJAXForms = new XMLHttpRequest(); } function CheckField(field) { if (window.XMLHttpRequest) { // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { AJAXForms = new ActiveXObject("Microsoft.XMLHTTP"); } AJAXForms.onreadystatechange = processChange; AJAXForms.open("POST", "check.php?op="+field.value); LastField = field.name; AJAXForms.send(null); } function processChange() { if (AJAXForms.readyState == 4) { var res = document.getElementById(LastField); res.innerHTML = AJAXForms.responseText; res.style.visibility = "visible"; } } html <input type="text" name="t0" value="" size="20" OnChange="CheckField(this)" tabindex="1"> <input type="text" name="t1" value="" size="20" OnChange="CheckField(this)" tabindex="1"> <div id="t0" class="message"></div> <div id="t1" class="message"></div> php var_dump ($_GET['op']) ; var_dump ($_GET['t1']); die(); Quote Link to comment 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.