I have a select form:
<form id="form" name="nameForm">
<select id="selectId" onchange="loadAjax('url.php');return false;">
<option>One</option
<option>Two</option>
</select>
</form>
I want that when the user changes the selected option, it loads the ajax function with the value in the url (trough GET).
So I tried several things and this was my last try:
onchange="
var e = document.getElementById('form');
var strSel = e.form.selectId.value;
loadAjax('url.php?v='+strSel);
return false;
">
Not really correct. Does someone know how to do this correctly ?
You are missing value attribute in options
I tried it and it works after adding value, like,
<select id="selectId" onchange="alert('url.php?v='+this.value);return false;">
<option value="one">One</option>
<option value="two">Two</option>
</select>
You should try this,
<select id="selectId" onchange="loadAjax('url.php?v='+this.value);return false;">
<option value="one">One</option>
<option value="two">Two</option>
</select>
According to your code sample this will work
onchange="
var e = document.getElementById('selectId');
var strSel = e.options[e.selectedIndex].value;
loadAjax('url.php?v='+strSel);
return false;
">