I'm trying to get this code to work dynamically. Basically i need the JS function to be generic per form and input textfield name. I believe my issue is in my form document declarations, my usage of the *dyn* variable.
FYI, If i make the text input name *dyn*, it works great.
Thanks. Cesar.
JavascriptHTMLCode:<script language="JavaScript"> function getData(dyn) { var req = null; document.this_form.dyn.value="Started..."; if(window.XMLHttpRequest) req = new XMLHttpRequest(); else if (window.ActiveXObject) req = new ActiveXObject(Microsoft.XMLHTTP); req.onreadystatechange = function() { document.this_form.dyn.value="Wait server..."; if(req.readyState == 4) { if(req.status == 200) { document.this_form.dyn.value="Received:" + req.responseText; } else { document.this_form.dyn.value="Error: returned status code " + req.status + " " + req.statusText; } } }; req.open("POST", "get.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send(null); } </script>Code:<FORM name="this_form" method="POST" action=""> <INPUT type="BUTTON" value="Submit" ONCLICK="getData('company_name')"> <input type="text" name="company_name" size="32" value=""> </FORM>




Bookmarks