PDA

Click to See Complete Forum and Search --> : Which option has been selected in Select tag with DHTML


Oct 2nd, 2000, 04:07 PM
Hi there I need to be able to find out which option has been selected in a Select tag within my page. I want to be able to do that dynamically. Here's what it should look like:

<html>
<head>
<script language=vbscript>

SUB WhichOption()
IF SelectObject.option(selectObject.selectedindex).value = "Training" THEN
{do something}
Else
{do something else}
END SUB
</script>
</head>

<select name="Event" onchange=WhichOption() size="1">
<option selected value="Meeting">Meeting</option>
<option value="Training">Training</option>
</select>

</html>


My only problem at this point is to determine the correct syntax to be used in the IF statement of my vbscript function. If you know the correct syntax please forward your suggestions. Thanks a lot for your time.

monte96
Oct 2nd, 2000, 05:47 PM
You've just about got it actually.. but I would not recommenf 'Event' as a name for the SELECT tag.



<html>
<head>
<script language=vbscript>
<!--
SUB WhichOption()
IF cboEvent.options(cboEvent.selectedindex).value = "Training" Then
{do something}
Else
{do something else}
End Sub
-->
</script>
</head>
<body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
<select name="cboEvent" onchange=WhichOption() size="1">
<option selected value="Meeting">Meeting</option>
<option value="Training">Training</option>
</select>
</body>
</html>