Rithish Saralaya wrote:
RobG <rg***@iinet.ne t.auau> wrote in message news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >...
As far as I can tell, no.
Actually speaking, this has been achieved too. However, I wasn't
confident of the solution. I do a 2-step selection. I select another
OPTION some indices below, and then select the actual OPTION. If I
have a SELECT list of 100 options of size 10, and the 50th OPTION is
to be selected, then, I first select the OPTION of index 60 ( required
OPTION index + list size ), and then select the OPTION of index 50.
This brings the 50th OPTION as the first item in the visible area.
But, as I said, I wasn't too confident of the solution. I wanted to
know if there were some methods like scrollToTop or something that
could be applied....
In a single select list, the selected item
is always made visible, but in a multi-select list (I'm guessing that
is what you are using) it does not scroll if the selected item is
out-of-view (i.e. off the bottom of the visible area).
It is indeed a single select list..
I'd been mulling this over for a while, and finally got to test it.
I've run the following code in every browser I can, yet the right
option is always made visible when the button is clicked.
What browser are you having issues with? I've tested it in IE and it
works fine.
Cheers, Rob.
<form action="">
<select name="aSelect">
<option value="opt1">op tion 1
<option value="opt2">op tion 2
<option value="opt3">op tion 3
<option value="opt4">op tion 4
<option value="opt5">op tion 5
<option value="opt6">op tion 6
<option value="opt7">op tion 7
<option value="opt8">op tion 8
<option value="opt9">op tion 9
<option value="opt10">o ption 10
<option value="opt11">o ption 11
<option value="opt12">o ption 12
<option value="opt13">o ption 13
<option value="opt14">o ption 14
<option value="opt15">o ption 15
<option value="opt16">o ption 16
<option value="opt17">o ption 17
<option value="opt18">o ption 18
<option value="opt19">o ption 19
<option value="opt20">o ption 20
<option value="opt21">o ption 21
<option value="opt22">o ption 22
<option value="opt23">o ption 23
<option value="opt24">o ption 24
<option value="opt25">o ption 25
</select><br>
<input type="reset"><b r><br>
<input type="text" cols="10" name="aNum">
Enter a number from 1 to 25 and that option will be selected<br>
<input type="button" value="click me" onclick="
var x = this.form.aNum. value;
if (x > 0 && x < 26) {
this.form.aSele ct.options[x - 1].selected='true '
} else {
alert('From 1 to 25 please, ' + x + ' is out of bounds');
}
">
</form>