Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

get value of next item in listbox after one item is dblclicked

I have a listbox

<SELECT size=10 onclick='vbscript:GetDataSel()' id=BLTrkOpts name=BLTrkOpts>
     <OPTION value='1'>Choice 1</OPTION>
     <OPTION value='2'>Choice 2</OPTION>
     <OPTION value='3'>Choice 3</OPTION>
     <OPTION value='4'>Choice 4</OPTION>

 If someone dbl clicks on "Choice 2" - i want to get the value of "Choice 3" placed into a textbox using a javascript function

  • 7
  • 6
1 Solution
ZvonkoSystems architectCommented:
Events on options do NOT work, only on the select object in complette.
And why do you want to confuse users????
ZvonkoSystems architectCommented:
Look yourself:

<select name="S1" onDblClick="this.form.T1.value=this.options[(this.selectedIndex<this.options.length-1)?this.selectedIndex+1:0].text" multiple>
<input type=text name="T1">

bigbillydotcomAuthor Commented:
Hey Zvonko
your example above is exactly what I wanted
I understand about the event on the select object, not on the options
just needed to figure out how to get that next value when the one above it is dbl clicked

>>And why do you want to confuse users????
not sure what you mean - but I tried to keep the question simple and didnt give a lot of details

actually - the text field will be a hidden field
that I will use the value of that hidden field
to set a session variable in an asp page

that session variable will then be used to
select the option that was just below the one that was being dbl clicked
when the page is posted to the server

the list is very long - and when an item is dbl clicked - that item is removed from the current list and placed into a different list box
i just wanted a way to put them back into the list at the point (well, down one notch) they were at when they dbl clicked

thanks again

i may post another question real quick about selecting an option in a list box from javascript (although i may be able to figure it out)

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

ZvonkoSystems architectCommented:
It seams you solve one problem by creating two new problems ;-)
bigbillydotcomAuthor Commented:
alas - its the programmers life I lead!
yo ho blow the man down!
ZvonkoSystems architectCommented:
Hey, take it funny...
bigbillydotcomAuthor Commented:
i did
bigbillydotcomAuthor Commented:
look for my new question
ZvonkoSystems architectCommented:
And seriously, is there a chance to avoid that option removal and remove the extra action of adding that removed option?
And why do you look for the next option after the doubleclicked and not the one actually doubleclicked.
Answer only if it helps you. I do not want to waste your time...

bigbillydotcomAuthor Commented:
hey zvonko - no problem

what is going on here is i have a form with two listboxes
one list box has a choice of available items (lets call it lbAvailItems) that comes from a database table (tblAvailItems)
the other is a listbox of selected items (lets call it lbSelItems) that comes from a database table (tblSelItems)

when they dbl click an item in lbAvailItems
the page refreshes and adds that item to tblSelItems

i already can capture the item dblclicked
you helped me determine the item that was next i nthe list when they dbl clicked

and when they return - i want to highlight that item that was next in the list at the time they dbl clicked because lbAvailItems is long lsit and I dotn want them to have to scroll all the way back down and try ot figure out wher ethey left off

Thanks again - that was a great answer!
I just posted the other question that is a different part of this
you da man!
ZvonkoSystems architectCommented:
Isn't it more convenient for you and the user NOT to submit the page on every dblclick, but to do the move on browser side and post the changed state to the server on page submit by Submit button?

bigbillydotcomAuthor Commented:
probably, but who cares about the user - HAHAHA
saves me from having to figure all that out
this page has been in use for a while and the main complaint was having to scroll back thru those boxes to find out where you left off
when they click an item - i se XMLHTTP to grab the descriptioon of the item from the dbase
i had this working fine - all client side without the page refresh
but XMLHTTP didnt want to work under SSL so i had to go back to the server side methods

one of these days I'll try to figure that out, but for now this works great

ZvonkoSystems architectCommented:
OK, as you like it. See you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now