hazelsisson
Programmer
Hello!
I've got a page which contains multiple (dynamically created) select boxes, and I'm trying to check that at least one of them has a selected value before the form is submitted.
The select boxes all have unique names, and are all single selects.
Here's the code:
The error (object doesn't support this property or method) is pointing to this line :
Can anyone spot anything wrong with it?!
Thanks!
Hazel
I've got a page which contains multiple (dynamically created) select boxes, and I'm trying to check that at least one of them has a selected value before the form is submitted.
The select boxes all have unique names, and are all single selects.
Here's the code:
Code:
function validateForm()
{
var chosen = "n";
var form = document.qForm;
for (i = 0; i < form.elements.length; i++)
{
if (form.elements[i].type == "select-one")
{
if (form.elements[i].options[form.elements[i].selectedIndex].value != "")
{
chosen = "y";
}
}
}
if (chosen == "n")
{
alert("Please choose a quote!")
}
else
{
document.qForm.submit();
}
}
The error (object doesn't support this property or method) is pointing to this line :
Code:
if (form.elements[i].options[form.elements[i].selectedIndex].value != "")
Can anyone spot anything wrong with it?!
Thanks!
Hazel