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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.