frank1002us Posted June 13, 2012 Share Posted June 13, 2012 the second value of the xmlhttpPost("test.php","c385982294011B") is not available in the function xmlhttpPost(strURL,form_name) . if i define a value for the form_name inside the function, it is passed with "getquerystring(form_name)" what is the stupid problem :'( <input value="Respond" type="button" onclick='javascript:xmlhttpPost("test.php","c385982294011B")'> function xmlhttpPost(strURL,form_name) { var xmlHttpReq = false; var self = this; // Mozilla/Safari formname=form_name; if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { updatepage(self.xmlHttpReq.responseText); } } self.xmlHttpReq.send(getquerystring(form_name)); } Quote Link to comment https://forums.phpfreaks.com/topic/264134-button-not-passing-variable-to-function/ Share on other sites More sharing options...
frank1002us Posted June 13, 2012 Author Share Posted June 13, 2012 if i put var form_name =<?php echo $form_name; ?>; inside the function xmlhttpPost(strURL,form_name) then it works. and if i put an alert instead of self.xmlHttpReq.send(getquerystring(form_name)); then i do get the correct values in the alert message but it will not pass the value of form_name to the other function Quote Link to comment https://forums.phpfreaks.com/topic/264134-button-not-passing-variable-to-function/#findComment-1353623 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.