N
Nick Calladine
Learning : Loop to list all dropdown box values on a form
Can some one point me in the right direction :
I have a form which I want to loop through
I basically want to get all the selected values of the option tag
see example below
<select name=itemname3 size="1"
onchange="calculatetotal(document.myform)">
<option value="2800 {466.73}" selected>2800 AMD 64 </option>
<option value="3000 {478.18}">3000 AMD 64</option>
<option value="3200 {505.20}">3200 AMD 64</option>
<option value="3400 {515.14}">3400 AMD 64</option>
<option value="3700 {617.14}">3700 AMD 64</option>
</select>
so i want to be able to read the option value ("2800 {466.73)") of the
string if it has been selected or is the default value.
The selectname of the dropdown boxes are all labeled itemname and increment
from 3 to variable x
heres my code so far
function caculatetotal(frm)
var order = 0
var counter = 0
for (counter=0 ; counter <frm.element.length; ++x) {
form_field=frm.elements[counter]
form_fieldname = form_field.name
if (form_fieldname.substring(0,8) == "itemname") {
}
}
}
so i basically need to start the loop to detect itemname3 onwards.. but not
too sure how to do this...
anyhelp would be appreciated.
thanks
Can some one point me in the right direction :
I have a form which I want to loop through
I basically want to get all the selected values of the option tag
see example below
<select name=itemname3 size="1"
onchange="calculatetotal(document.myform)">
<option value="2800 {466.73}" selected>2800 AMD 64 </option>
<option value="3000 {478.18}">3000 AMD 64</option>
<option value="3200 {505.20}">3200 AMD 64</option>
<option value="3400 {515.14}">3400 AMD 64</option>
<option value="3700 {617.14}">3700 AMD 64</option>
</select>
so i want to be able to read the option value ("2800 {466.73)") of the
string if it has been selected or is the default value.
The selectname of the dropdown boxes are all labeled itemname and increment
from 3 to variable x
heres my code so far
function caculatetotal(frm)
var order = 0
var counter = 0
for (counter=0 ; counter <frm.element.length; ++x) {
form_field=frm.elements[counter]
form_fieldname = form_field.name
if (form_fieldname.substring(0,8) == "itemname") {
}
}
}
so i basically need to start the loop to detect itemname3 onwards.. but not
too sure how to do this...
anyhelp would be appreciated.
thanks