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
https://forums.phpfreaks.com/topic/201456-passing-select-value/
Share on other sites

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.