PDA

View Full Version : scrolling a listbox


jeorg
09-20-2002, 09:43 AM
I have a long<SELECT> how can I directly scroll to the first selected item ? tank you

umm
09-20-2002, 10:09 AM
Hi, do you mean that you want a default selected item in the select list? I don't quite understand your question.

jeorg
09-20-2002, 01:44 PM
no my select is server side fill from a database and the items are allready selected
it is for an update
if one of the last item is selected you don't see it at once that
then I would like to scroll to the first selected item

....to the first because generally I use a multiselect

thank you

rageybabey
09-20-2002, 02:07 PM
If you want it so that when someone clicks on an option in your drop down the list bounces back to the first item, insert this line of code into your first <select> tag...

onChange="MM_jumpMenu('parent',this,1)"

If you change the 1 to a zero it will reverse the effect.

Bosko
09-20-2002, 03:21 PM
If you have a select,you can set put the selected="selected" attribute in an option and it will scroll to that item.
Heres an example:

<select>
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
<option value="5">five</option>
<option value="6">six</option>
<option value="7">seven</option>
<option value="8">eight</option>
<option value="9">nine</option>
<option value="10">ten</option>
<option value="11" selected="selected">eleven</option>
</select>

jeorg
09-20-2002, 03:28 PM
strange it doesn't work


I have that kind

<select>
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
<option value="5">five</option>
<option value="6">six</option>
<option value="7">seven</option>
<option value="8">eight</option>
<option value="9">nine</option>
<option value="10">ten</option>
<option value="11" selected="selected">eleven</option>
</select>


but it doesn't scroll to the number 11 (in that case) so I dont know if soemthing is selected or not , I think I must ask to an asp net section ..

thanks to all !

Bosko
09-20-2002, 04:57 PM
Eh,the "eleven" option is selected and visible,I tested it in Mozilla,Konqueror and even Lynx...

jeorg
09-21-2002, 08:10 AM
yes you are right into a normal html page it works
I must look what's the reason ... ASP NET is super but sometimes !....:-)))

thank you

Bosko
09-21-2002, 10:37 AM
Lol,okay :)