473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Select option on right click

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
1 3488
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
1
by: Mariusz | last post by:
Hi does anyone know an easy way to define object <select> in that way when clicking on it works as right alt is used. In other words - I need to rebuild select than when I click on first option...
1
by: araripe | last post by:
Hi I would like to be able to right click on a select box and capture which element (option object) the mouse is over. The option is not previously selected. Indeed, I want to select it using the...
1
by: HJ Majoue | last post by:
I am having a problem with RichTextBox Control and hope you can help I am working on a VB.Net project that has a RTB control, the user opens a form template. What I want to do is for a user to be...
7
by: sean | last post by:
SELECT drop-list width incorrect for long text when SELECT is fixed width Setting the width style of a SELECT statement causes the contents of the drop-list to be cropped. This is problematic...
4
by: gregincolumbus | last post by:
I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes. Ideally, a change of...
8
by: crayfiss | last post by:
Hi, firstly I am a total freshie in all this. From what I have gathered on the web and this forum, I finally managed to get my form up. I have a set of radio buttons with values to it and a select...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.