PDA

View Full Version : 2 dropdown lists



John76
Aug 29th, 2003, 09:49 PM
Hi,

I have 2 dropdown list for a specific product to be ordered, that need to be required when the user clicks the "Add to Cart" button.

I can't figure out how to make dropdown lists required? Here are the selection lists.

Product Type -
<SELECT NAME="ProductNo" STYLE="font-family: Arial; font-size: 8pt; height:20px;">
<OPTION VALUE="">Select Style / Color</OPTION>
<OPTION VALUE="Product 1 - 876 ($ 49.95)">Product 1 - 876 ($ 49.95)</OPTION>
<OPTION VALUE="Product 2 - 976 ($ 49.95)">Product 2 - 976 ($ 49.95)</OPTION>
<OPTION VALUE="Product 3 - 1076 ($ 49.95)">Product 3 - 1076 ($ 49.95)</OPTION>
<OPTION VALUE="Product 4 - 1176 ($ 49.95)">Product 4 - 1176 ($ 49.95)</OPTION>
</SELECT>

and

Size -
<SELECT NAME="Size" STYLE="font-family: Arial; font-size: 8pt; height:20px;">
<OPTION VALUE="">Select Size</OPTION>
<OPTION VALUE="5">5</OPTION>
<OPTION VALUE="5.5">5&frac12;</OPTION>
<OPTION VALUE="6">6</OPTION>
<OPTION VALUE="6.5">6&frac12;</OPTION>
<OPTION VALUE="7">7</OPTION>
<OPTION VALUE="7.5">7&frac12;</OPTION>
<OPTION VALUE="8">8</OPTION>
<OPTION VALUE="8.5">8&frac12;</OPTION>
<OPTION VALUE="9">9</OPTION>
<OPTION VALUE="9.5">9&frac12;</OPTION>
<OPTION VALUE="10">10</OPTION>
<OPTION VALUE="11">11</OPTION>
</SELECT>



Thanks in advance.

John

Vincent Puglia
Aug 29th, 2003, 10:21 PM
see if the selectedIndex is equal to 0; if so, then nothing was selected and the form shouldn't be submitted

for the actual code: use the search button

Vinny

John76
Aug 30th, 2003, 12:08 AM
Here is the script I'm using:

<SCRIPT LANGUAGE="JavaScript">
<!--
function chkForm(f) {
if (f.ProductNo.value == "") {
alert ("Please select - STYLE / COLOR");
f.ProductNo.focus();
return false;
}

if (f.Size.value == "") {
alert ("Please select - SIZE");
f.Size.focus();
return false;
}

}
// -->
</SCRIPT>

The size script works by itself, but when I try to use them both, neither one works.

John76
Aug 30th, 2003, 07:08 PM
I figured out what I was doing wrong...thanks for the help Vinny.

John