Canman2005 Posted May 12, 2010 Share Posted May 12, 2010 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 More sharing options...
Zane Posted May 12, 2010 Share Posted May 12, 2010 Use the plus sign for concatenation in Javascript onChange="ajaxLoader('product_list.php?value='+this.value,'contentarea');" Link to comment https://forums.phpfreaks.com/topic/201456-passing-select-value/#findComment-1056927 Share on other sites More sharing options...
Canman2005 Posted May 12, 2010 Author Share Posted May 12, 2010 thank you very much Link to comment https://forums.phpfreaks.com/topic/201456-passing-select-value/#findComment-1056928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.