Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form validation, netscape <select> problem

Status
Not open for further replies.

karly

Technical User
Mar 8, 2003
1
US
Hello,

I've written a function that checks -when the form is submitted- if they have selected a value that isn't the value "Select" ... the function works in IE but not in Netscape browsers .. what am I doing wrong ?

Here is the function:

function checksize()
{
if (document.product_detail.ProductSize.value=="Select")
{
alert("Please select a size ...");
document.product_detail.ProductSize.focus();
return false;
}
return true
}


This is the select and the form tag:

<form method=&quot;post&quot; name=&quot;product_detail&quot; action=&quot;shoppinglist.asp&quot; onSubmit=&quot;return checksize()&quot;>

<select size='1' name='ProductSize'><option value='Select' selected>Select</option><option value='16_inches'>16 inches</option><option value='40_cm'>40 cm</option></select>
 
Unfortunately, with Netscape, you need to retrieve the value of the option object that was selected from the select box. Here's a routine I wrote to deal with this. Pass a reference to the select box:

function GetSelectValue(oSelectBox)
{
var iSelected = -1;
if (oSelectBox)
{
iSelected = oSelectBox.selectedIndex;
return oSelectBox[iSelected].value;
}
else
return &quot;&quot;;

}

nick bulka

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top