Select option on right click

D

Dan Williams

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top