Forum Moderators: open

Message Too Old, No Replies

Drop down selection required

         

geekwannabe

11:45 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



I have two drop down boxes using javascript. The user has to choose something from the first box in oder to populate the second box. Unfortunately some people will select an option from the first box and not select anything from the second one. I would like to make some kind of pop up or something asking people to please select something from that second box before continuing to the validation page.

Here is the code that I have for the javascript for the two boxes:

if(MM_findObj('firstname').value.length < 2 ¦¦ MM_findObj('lastname').value.length < 2 ¦¦ MM_findObj('street').value.length < 2 ¦¦ MM_findObj('city').value.length < 2 ¦¦ MM_findObj('prodName').value.length < 2){
MM_findObj('firstname').className='error';
MM_findObj('lastname').className='error';
MM_findObj('street1').className='error';
MM_findObj('city').className='error';
MM_findObj('prodName').className='error';
errors+='The Highlighted spaces must have at least 2 characters. Please make sure you have the product name included.\n';
}
if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
function setOptions(chosen) {
var selbox = document.rmavalidation.opttwo;

selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--',' ');

}
if (chosen == "MFS") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--');
selbox.options[selbox.options.length] = new Option('');
selbox.options[selbox.options.length] = new Option('');
}
if (chosen == "EH") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--');
selbox.options[selbox.options.length] = new Option('');
selbox.options[selbox.options.length] = new Option('');
}
if (chosen == "FM") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--');
selbox.options[selbox.options.length] = new Option('');
selbox.options[selbox.options.length] = new Option('');
}
if (chosen == "MM") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--');
selbox.options[selbox.options.length] = new Option('');
selbox.options[selbox.options.length] = new Option('');
}
if (chosen == "DC") {
selbox.options[selbox.options.length] = new Option('--Please choose a model--');
selbox.options[selbox.options.length] = new Option('');
selbox.options[selbox.options.length] = new Option('');
}
}

and this is in the html code for the two boxes:

<tr>
<td><font color="red">*</font>Product Category:<br /> </td>
<td ><select name="optone" size="1"
onchange="setOptions(document.rmavalidation.optone.options[document.rmavalidation.optone.selectedIndex].value);" required>
<option>--Please choose a category--</option>
<option value="MFS<font size="-1">TM</font></option>
<option value="EH</option>
<option value="FM</option>
<option value="Digital Cables">DC</option>
<option value="MM</option>

</select><br /><br /></td></tr>
<tr><td><font color="red">*</font>Product Model:<br /></td><td>
<select name="opttwo" size="1" required>
<option value>--Please Choose a Model--</option>
</select> <br /><br />
</td>
</tr>

Thank you so much for your help with this. I really appreciate any point in the right direction.

geekwannabe

10:00 pm on Feb 11, 2008 (gmt 0)

10+ Year Member



hmmm nobody has an idea? Do you think that I have it right so far with Javascript?