Click to See Complete Forum and Search --> : Quick question, but I can't figure it out...


sonicsix
05-07-2003, 02:20 PM
I have a form with a select input like this:

<select name="AIM_REV" size="1">
<option value="">-- Select Revision --</option>
<option value=""></option>
</select>

The options are filled in by a database so I don't know in advance how many there will be.

What I need is an onChange script that will simply do an alert if the user selects any option OTHER than the very last one.

Thanks!

Jona
05-07-2003, 02:25 PM
Using the onLoad event:

function slct_len(){
var len = document.myForm.mySelectbox.options.length;
if(document.myForm.mySelectbox.options[document.myForm.mySelectbox.options.selectedIndex] < len){ alert("Please select the last one, but don't ask me why."); }
}

sonicsix
05-07-2003, 02:50 PM
OK, that pointed me enough to figure it out... thanks!


function goRevision()
{
with (document.theForm.AIM_REV) {
var i = options.length - 1;
var x = options.selectedIndex;
if(x < i)
{
alert("Are you sure you want to use this revision?\n");
}
}
}

Jona
05-07-2003, 02:57 PM
You're welcome!