连动html(select)标签操作 原创(create by le)
2010-11-01 10:12
429 查看
代码是最好的解释,请看代码,呵呵!
代码
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;
}
}
代码
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;
}
}
相关文章推荐
- 通过JavaScript操作HTML中select标签
- HTML中select标签单选多选详解--Js操作Select大全
- JS对HTML标签select的获取、添加、删除操作
- html下拉框(select元素标签)的基本操作
- (原创)利用扩展方法,给 IEnumerable<T> 增加一个生成 Html 的 select 标签的方法,不用 C# 中的反射技术
- html select标签操作
- JS对HTML标签select的获取、添加、删除操作
- 封装html的select标签的js操作
- jq获取HTML中select标签option值的操作
- 通过JavaScript操作HTML中select标签
- html标签[select]js操作
- 【DOM操作】DOM操作HTML中的Select标签
- JQuery操作html中select标签
- 使用 js + button标签 模拟 select 列表框 操作 By shawl.qiu
- 封装html的select标签的js操作实例
- 通过JavaScript操作HTML中select标签(转)
- 通过JavaScript操作HTML中select标签
- Oracle 树操作(select…start with…connect by…prior)
- Java操作HTML格式字符串的标签和属性
- html之select标签