Scrolling multiple-select, IE vs Firefox
- From: "johkar" <nosendjunk@xxxxxxx>
- Date: 29 Apr 2006 13:04:30 -0700
Why does this code work in IE and Firefox and the second example does
not work in IE. While these are just sample scripts, my actual scripts
will be transferring options from one multi-select list to another. I
want the most recently added one to scroll into view.
Works in both:
<html>
<head>
<title>test</title>
</head>
<body>
<form>
<select name="a" multiple size="5" style="width:200px">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
<input type="button" value="Set"
onclick="this.form.elements['a'].options[8].selected=true">
</form>
</body>
</html>
Does not work in IE. Added option not scrolled into view.
<html>
<head>
<script type="text/javascript">
function addit(myForm,myElm){
var opt = new Option('my new option', 'value');
var sel = myElm;
sel.options[sel.options.length - 1].selected=false;
sel.options[sel.options.length] = opt;
sel.options[sel.options.length - 1].selected=true;
}
</script>
</head>
<body>
<form>
<select name="a" multiple size="5" style="width:200px">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
<input type="button" value="Set"
onclick="addit(this.form,this.form.elements['a'])">
</form>
</body>
</html>
.
- Follow-Ups:
- Re: Scrolling multiple-select, IE vs Firefox
- From: Csaba Gabor
- Re: Scrolling multiple-select, IE vs Firefox
- Prev by Date: Re: FAQ Posting problem
- Next by Date: Re: Cookie problem! Getting error when passing the expire date.
- Previous by thread: Simple totalling of a column with onChange()
- Next by thread: Re: Scrolling multiple-select, IE vs Firefox
- Index(es):