Reputation: 223
I've got a dynamic dropdownbox:
function chgAantal(i,artNr,lengte){
var aantal=document.getElementById("aantal_"+i).value;
if(isNaN(aantal)){
alert('Voer een geldig aantal in...');
document.all["error_"+i].src="/images/fout.gif";
ok=0;
}
else{
location.href="addcart.asp?act=change&aantal="+aantal+"&artNr="+artNr+"&lengte="+lengte+"&bdr=<%=bdr%>";
}
}
<select onchange='chgAantal(\""+i+"\",\""+artNr+"\",\""+lengte+"\")' name='aantal_"+i+"' value='"+aantal+"'/>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
</select>
When I change the value in (for example) 7, the value changes in the script. But I can't see the selected value, the value displaying is always 1. How can I display the selected value?
I hope you understand me!
Regards,
Fraak
Upvotes: 0
Views: 249
Reputation: 597
code is perfect i think problem is with onchange check if the variables u have declared is proper
Upvotes: 0
Reputation: 2964
You should not be specifying the value in the Select tag as is determined by the selected option. Useful DOM properties for working with select Elements are:
selectedIndex: gets/sets the Id of the selected option.
value: returns the value of the selected option.
What you need to do here is change selectedIndex.
https://developer.mozilla.org/en/DOM/HTMLSelectElement
Upvotes: 1