Jump to content

Passing select value


Canman2005

Recommended Posts

Hi all

 

I have a content loading script

 

function ajaxLoader(url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
el = document.getElementById(id);
        el.innerHTML = "";

      if (x.readyState == 4 && x.status == 200) {
        el = document.getElementById(id);
        el.innerHTML = x.responseText;
      }
    }
    x.open("GET", url, true);
    x.send(null);
  }
}

 

which works great.

 

I then have a drop down HTML list which looks like

 

<select name="products" onChange="ajaxLoader('product_list.php?value=(this.value)','contentarea');">
<option value="1">Apple</option>
<option value="2">Dell</option>
<option value="3">Logitech</option>
</select>

 

I then have a SPAN area

 

<span id="contentarea"></span>

 

in which "product_list.php" loads in.

 

all I want to do, is pass the value of whatever option was selected

 

So if "Dell" was selected, the call would be

 

onChange="ajaxLoader('product_list.php?value=2','contentarea');"

 

and if "Apple" was selected, the call would be

 

onChange="ajaxLoader('product_list.php?value=3','contentarea');"

 

but using

 

(this.value)

 

doesn't seem to be passing the selected value in the list

 

can anyone help? I'm totally stumpted

 

Thanks

 

Dave

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.