Results 1 to 2 of 2

Thread: Which option has been selected in Select tag with DHTML

  1. #1
    Guest

    Question

    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.





  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You've just about got it actually.. but I would not recommenf 'Event' as a name for the SELECT tag.


    Code:
    <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>
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width