用js分别获取select的value 和 text 文本
来源:互联网 发布:本色服饰淘宝旗舰店 编辑:程序博客网 时间:2024/05/08 08:36
<td nowrap="nowrap">
<div align="center">
环节:
</div>
</td>
<td>
<html:select name="departmentDeclareForm" property="cycleId">
<html:options collection="cycleList" property="value"
labelProperty="name" />
</html:select>
<input type="hidden" name="oldCycleId"/>
</td>
1.获取 cycleId 的value 即 id值
newRow.cells(1).innerText =document.forms[0].elements("cycleId").value;//环节
2.获取 cycleId 的text 即静态文本
newRow.cells(1).innerText =document.forms[0].elements("cycleId").options[document.forms[0].elements("cycleId").selectedIndex].text;//环节
或者:
var ops = document.forms[0].elements("cycleId").options;
var idx = document.forms[0].elements("cycleId").selectedIndex;
alert(ops[idx].text);
下面是从网上找到的一个方法
Script language= "javascript ">
function query() {
alert(form1.select.options[form1.select.selectedIndex].text);
if(form1.select.options[form1.select.selectedIndex].text== "计算机 "){
return form1.select.options[form1.select.selectedIndex].text;
}else if(form1.select.options[form1.select.selectedIndex].text== "机械系 "){
return form1.select.options[form1.select.selectedIndex].text;
}else if(form1.select.options[form1.select.selectedIndex].text== "电子系 "){
return form1.select.options[form1.select.selectedIndex].text;
}else if(form1.select.options[form1.select.selectedIndex].text== "数学系 "){
return form1.select.options[form1.select.selectedIndex].text;
}
}
</script>
<form name= "form1 ">
<select name= "select ">
<option value= "0 "> 请选择 </option>
<option> 机械系 </option>
<option> 电子系 </option>
<option> 数学系 </option>
<option> 计算机 </option>
</select>
<input type= "button " value= "确定 " onclick= "query() ">
</form>
- 用js分别获取select的value 和 text 文本
- JS 获取select的value和text值
- 关于JS获取select的值(value和text)
- 利用js获取select的value和text值
- js 获取select标签的value 和 text
- JS获取select对象的value Text
- js获取select的value或者text
- jquery 获取select的value和text
- Jquery 获取选中的Select的Text文本值和Value值。
- jQuery获取Select选择的Text(文本信息)和 Value属性的值,select语法解释;单选框和复选框
- JS获取TreeView的Text和Value
- js获取<select>下拉菜单的value值和text值
- js实例,获取选中select标签的value和option text值
- js/jq 获取select下拉框的文本值和value值
- jquery select option 根据value值获取text文本,option中间的文本
- javascript获取select 中value和text的值
- jQuery获取Select选择的Text和 Value(转)
- jQuery获取Select选择的Text和 Value(转)
- 鼠标经过图片晃动效果
- 计算机的发展史
- 36岁IT“老人”再次随笔
- MCS-51单片机模拟I2C软件包(转)
- prefuse关系图开源包
- 用js分别获取select的value 和 text 文本
- 串口扩展卡的发展史
- PE文件中各IMAGE_DATA_DIRECTORY的定义
- Android中的NotificationManager
- word study of unit 4
- 在UDP中使用connect
- ubuntu9.04里的中文输入法设置
- 【转】--使用肖波的KTDictSeg分词器 为Lucene.net服务
- 历代Windows操作系统