Solved

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

Posted on 2006-06-15
13
620 Views
Last Modified: 2008-02-01
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>
</SELECT>      

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

0
Comment
Question by:bigbillydotcom
  • 7
  • 6
13 Comments
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Events on options do NOT work, only on the select object in complette.
And why do you want to confuse users????
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
Comment Utility
Look yourself:

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

0
 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
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)





0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
It seams you solve one problem by creating two new problems ;-)
0
 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
alas - its the programmers life I lead!
yo ho blow the man down!
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Hey, take it funny...
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
i did
thanks!
0
 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
look for my new question
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
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...

0
 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
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!
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
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?

0
 
LVL 13

Author Comment

by:bigbillydotcom
Comment Utility
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

THANKS TO THE Zvonko!!
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
OK, as you like it. See you.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now