tasox
05 May 2011, 07:16 AM
hello everybody!!
if you have many select tags how i can find the selections form every select tag??please in javascript code!!
i wrote this but it's wrong because this code gives me the values from the first select tag
function getoptionvalues() {
var t="select30";
for(var i=0;i<document.getElementById(t).length;i++){
var x=document.getElementById(t)[i].value;
alert(x); } }
for example
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
if you have many select tags how i can find the selections form every select tag??please in javascript code!!
i wrote this but it's wrong because this code gives me the values from the first select tag
function getoptionvalues() {
var t="select30";
for(var i=0;i<document.getElementById(t).length;i++){
var x=document.getElementById(t)[i].value;
alert(x); } }
for example
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<select id="select30">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>