Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox double click event 2

Status
Not open for further replies.

newprogrammer999

Programmer
Aug 28, 2002
26
IE
Hi all,

At the moment I have a list box with items from a datbase in it. I want to be able to double clck on one of the items and then this will open a page with the full details for this item. My problem is though that I cannot find how to do a listbox dbl_click event or even if it is possible at all. Any help on this would be greatly appreciated,

Regards,
benny
 
<scratches head>

First, the obvious question, why force a dbl click?

If you must, why not just trap the first click, do nothing with it, then act on the second click.

But why?

</scratches head>



Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
I have a vb program that i am replicating in asp. There are places in the program that I want to be able to double click on items in list boxes to move them in to other areas. I started doing it this way because I could not see any reason why it would not work - its just i can't seem to find how to do it.

At the moment I allow the user to select an item in the list box and then click a button to perform the action but there must be an easier way of doing things.

Regards,
benny
 
Still doesn't make sense to me. If a single click works let it. If they dbl click, the 2nd click will be ineffective won't it?

Whatever...

Use the Javascript onClick and onDblClick functions.

You could even go as far as onClick=&quot;alert('Sorry, you must double click')&quot; :eek:)

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
Be careful mixing onClick and onDblClick events. The way the double click event is fired is by receiving a second click shortly after a first click. That first click fires the onClick event, so when you put both on an element, a double click will first fire the onClick event and then the onDblClick event.

Here's an example:
Code:
<input type=&quot;submit&quot; value=&quot;button&quot; name=&quot;btnSubmit&quot; onClick=&quot;document.getElementById('spnClick').innerText += 'Single Click';&quot; onDblClick=&quot;document.getElementById('spnDblClick').innerText += 'Double Click';&quot;>
<span id=&quot;spnClick&quot;></span>
<span id=&quot;spnDblClick&quot;></span>

You will notice that no mater how fast you double click, the onClick event still gets registered after you click the first time.

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
You are likely correct Tarwn.

Never done it as I never seen the point of dbl clicking...who's idea was that in the first place anyway? :p

newprgrammer, instead you could use onClick to fire a function, set a variable for a period (1 sec?), if the variable is set then assume it is a dbl click, if not...well, why not fire the function anyway.

I was reading a report the other day that has discovered that due to the increasing number of comuters and mouses associated with them, we are running out of clicks and there is going to be a worldwide click shortage in 2007.

So anything we, as programmers can do to conserve clicks is a good thing. Go for the single click every time. In fact, as programmers we can all do the right thing and promote the use of the enter key instead of clicking.



Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
Thanks for the help guys - if its too much work then I will probably leave it at a single click. I suppose I'm just too used to doing things in vb. Thanks for the advice anyway.

Regards
benny
 
<whispers>

Hey Tarwn, I think he believed me about the click shortage

</whispers>

<ducks for cover>

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
The star was for your help over all - not the bad programming joke.

Regards,
benny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top