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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resetting select nox

Status
Not open for further replies.

larsgrill

Programmer
Aug 6, 2003
9
DK
I have a HTML page with two select boxes. For those I've made a Javascript function that resets them both by setting selectedIndex = -1. This works alright.
Now I want to add this functionality: When resetting the scrollbars should be moved to the beginning of the lists.
Anyone who knows how to do this?
Regards, Lars Grill
 
Lars,

I may not quite understand what you are asking, but if you want to make sure the first option of the select list is chosen, you would say something like this:

Code:
formName.selectListName.options[0].selected = true;

Am I understanding what you were asking correctly?

--Dave
 
Hi Dave

I'm sorry, but that's not what I meant. By resetting I actually mean the opposite of what you've suggested, ie. remove any selection.
My problem is basically moving the scrollbars at the same time, so that the list boxs show the first items in the list.
Hope this explains it.
Lars.
 
I'm guessing you're working with a multiple select box.

How about this?
formName.selectListName.selectedIndex=0;
formName.selectListName.selectedIndex=-1;

Adam
 
Thanks Adam! It works!
Now I feel a bit stupid, because it's such a simple solution.
Best regards, Lars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top