?
Solved

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

Posted on 2006-06-15
13
Medium Priority
?
631 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 16913418
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 2000 total points
ID: 16913469
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
ID: 16913776
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 63

Expert Comment

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

Author Comment

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

Expert Comment

by:Zvonko
ID: 16913925
Hey, take it funny...
0
 
LVL 13

Author Comment

by:bigbillydotcom
ID: 16913952
i did
thanks!
0
 
LVL 13

Author Comment

by:bigbillydotcom
ID: 16913957
look for my new question
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16913959
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
ID: 16914075
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
ID: 16914162
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
ID: 16914209
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
ID: 16914345
OK, as you like it. See you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
Suggested Courses

770 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