Jump to content

button not passing variable to function


frank1002us

Recommended Posts

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));
}

Link to comment
https://forums.phpfreaks.com/topic/264134-button-not-passing-variable-to-function/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.