By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,081 Members | 1,885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,081 IT Pros & Developers. It's quick & easy.

Select option on right click

P: n/a
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.selectedInde x).text, _
4,"Delete message?")
end if
end sub

sub fnViewMsg
Call MsgBox(form1.messages.Options(form1.messages.selec tedIndex).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>
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Oh. Sorry about that.

Any other helpful takers?

Dan

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.selectedInde x).text, _
4,"Delete message?")
end if
end sub

sub fnViewMsg
Call
MsgBox(form1.messages.Options(form1.messages.selec tedIndex).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>


Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.