连动html(select)标签操作 原创(create by le)
时间:2010-11-01 来源:陈力
代码是最好的解释,请看代码,呵呵!
代码 function ChangeCustomId(obj) {
var opt = obj.options[obj.selectedIndex]
//alert("The option you select is:" + opt.text + "(" + opt.value + ")");
var opt = obj.options[obj.selectedIndex]
var selectItem = document.getElementsByName("mySelect1");
for (i = 0; i < selectItem.length; i++) {
selectItem[i].selectedIndex = obj.selectedIndex;
}
}
<select id="mySelect" name="mySelect" onchange="ChangeCustomId(this)"><option>1</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>9</option>
<option>10</option>
<option>14</option>
<option>15</option>
<option>16</option>
</select>
</th>
function ChangeCustomId(obj) {
var opt = obj.options[obj.selectedIndex]
//alert("The option you select is:" + opt.text + "(" + opt.value + ")");
var opt = obj.options[obj.selectedIndex]
var selectItem = document.getElementsByName("mySelect1");
for (i = 0; i < selectItem.length; i++) {
selectItem[i].selectedIndex = obj.selectedIndex;
}
}
相关阅读 更多 +