本文发表在 rolia.net 枫下论坛My problem is caused by mulitple select box, I want to show mulitple selected item ,
<select id=s2[] name=s2 MULTIPLE size=6>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4 >4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14 selected>14</option>
<option value=15 selected>15</option>
<option value=16>16</option>
</select>
In Firefox/Mozilla, when the page is loaded, the select automatically scrolldown to the first selected item, which is what I want. but in IE , it stay in the first low.
I tried :
<input type=button value=test onclick="Javascript:moveSelect()">
<script language="JavaScript">
<!--
var ie5=document.all
var ns6=document.getElementById&&!document.all
function FIND(item) {
if( window.mmIsOpera ) return(document.getElementById(item));
if (document.all) return(document.all[item]);
if (document.getElementById) return(document.getElementById(item));
return(false);
}
function moveSelect()
{
obj= FIND('s2');
idx= obj.selectedIndex;
obj.selectedIndex=idx;
}
//-->
</script>
The select did scroll down, but I lost a selection. so the final solution is
function moveSelect1()
{
obj= FIND('s2');
var length= obj.options.length;
var arr =new Array();
for ( i=0;i<length;i++)
{
arr[i]=obj.options[i].selected;
}
idx= obj.selectedIndex;
obj.selectedIndex=idx;
for ( i=0;i<length;i++)
{
obj.options[i].selected=arr[i];
}
}
But unfortunately, It didn't work on safari :-(更多精彩文章及讨论,请光临枫下论坛 rolia.net
<select id=s2[] name=s2 MULTIPLE size=6>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4 >4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14 selected>14</option>
<option value=15 selected>15</option>
<option value=16>16</option>
</select>
In Firefox/Mozilla, when the page is loaded, the select automatically scrolldown to the first selected item, which is what I want. but in IE , it stay in the first low.
I tried :
<input type=button value=test onclick="Javascript:moveSelect()">
<script language="JavaScript">
<!--
var ie5=document.all
var ns6=document.getElementById&&!document.all
function FIND(item) {
if( window.mmIsOpera ) return(document.getElementById(item));
if (document.all) return(document.all[item]);
if (document.getElementById) return(document.getElementById(item));
return(false);
}
function moveSelect()
{
obj= FIND('s2');
idx= obj.selectedIndex;
obj.selectedIndex=idx;
}
//-->
</script>
The select did scroll down, but I lost a selection. so the final solution is
function moveSelect1()
{
obj= FIND('s2');
var length= obj.options.length;
var arr =new Array();
for ( i=0;i<length;i++)
{
arr[i]=obj.options[i].selected;
}
idx= obj.selectedIndex;
obj.selectedIndex=idx;
for ( i=0;i<length;i++)
{
obj.options[i].selected=arr[i];
}
}
But unfortunately, It didn't work on safari :-(更多精彩文章及讨论,请光临枫下论坛 rolia.net