Select option on right click

Discussion in 'ASP General' started by Dan Williams, Jul 2, 2003.

  1. Dan Williams

    Dan Williams Guest

    I have a simple select form element object and want to be able to get it to
    select whatever the user chooses when they right-click in it.

    I've managed to use the following code, but on the right-click it displays
    whatever was previously selected and still highlighted with the left click.

    Is there a way to get a right click in the select object to perform the same
    functionality as a left click? (ie. select the option)

    <html>
    <head>
    <script language="VBScript">
    <!--

    sub fnDelMsg
    if window.event.button = 2 then
    Call MsgBox("Are you sure you wish to delete this message?" _
    & vbcrlf & vbcrlf &
    form1.messages.Options(form1.messages.selectedIndex).text, _
    4,"Delete message?")
    end if
    end sub

    sub fnViewMsg
    Call MsgBox(form1.messages.Options(form1.messages.selectedIndex).text, _
    ,"Message details")
    end sub

    -->
    </script>

    <body>
    <form name="form1">
    <select name="messages" size="8" onDblClick="fnViewMsg()"
    onMouseDown="fnDelMsg()">
    <option>Message 1</option>
    <option>Message 2</option>
    <option>Message 3</option>
    <option>Message 4</option>
    </select>
    </form>
    </body>
    </html>
     
    Dan Williams, Jul 2, 2003
    #1
    1. Advertising

  2. Dan Williams

    Dan Williams Guest

    Oh. Sorry about that.

    Any other helpful takers?

    Dan

    "Bob Barrows" <> wrote in message
    news:%...
    > This is an asp group - server-side code questions only. You need to ask

    this
    > in a group with "dhtml" in its name...oh! you crossposted to
    > scripting.vbscript! That group is relevant.
    >
    > Bob
    > Dan Williams wrote:
    > > I have a simple select form element object and want to be able to get
    > > it to select whatever the user chooses when they right-click in it.
    > >
    > > I've managed to use the following code, but on the right-click it
    > > displays whatever was previously selected and still highlighted with
    > > the left click.
    > >
    > > Is there a way to get a right click in the select object to perform
    > > the same functionality as a left click? (ie. select the option)
    > >
    > > <html>
    > > <head>
    > > <script language="VBScript">
    > > <!--
    > >
    > > sub fnDelMsg
    > > if window.event.button = 2 then
    > > Call MsgBox("Are you sure you wish to delete this
    > > message?" _ & vbcrlf & vbcrlf &
    > > form1.messages.Options(form1.messages.selectedIndex).text, _
    > > 4,"Delete message?")
    > > end if
    > > end sub
    > >
    > > sub fnViewMsg
    > > Call
    > > MsgBox(form1.messages.Options(form1.messages.selectedIndex).text,
    > > _ ,"Message details")
    > > end sub
    > >
    > > -->
    > > </script>
    > >
    > > <body>
    > > <form name="form1">
    > > <select name="messages" size="8" onDblClick="fnViewMsg()"
    > > onMouseDown="fnDelMsg()">
    > > <option>Message 1</option>
    > > <option>Message 2</option>
    > > <option>Message 3</option>
    > > <option>Message 4</option>
    > > </select>
    > > </form>
    > > </body>
    > > </html>

    >
    >
     
    Dan Williams, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laughlin, Joseph V

    Right-click brings up an option menu

    Laughlin, Joseph V, May 24, 2004, in forum: Python
    Replies:
    0
    Views:
    351
    Laughlin, Joseph V
    May 24, 2004
  2. sivabejawada
    Replies:
    0
    Views:
    291
    sivabejawada
    Oct 7, 2008
  3. Alex DeCaria
    Replies:
    2
    Views:
    105
    Alex DeCaria
    Feb 22, 2010
  4. Saravanan K
    Replies:
    2
    Views:
    109
    Grant Wagner
    Nov 19, 2004
  5. araripe
    Replies:
    1
    Views:
    106
    Thomas 'PointedEars' Lahn
    May 28, 2005
Loading...

Share This Page