js取下拉列表
function changecompanyTypeId(obj){
if(obj&&obj.options&&obj.selectedIndex>-1&&obj.options[obj.selectedIndex]){
var curValue=obj.options[obj.selectedIndex].value;
var curText=obj.options[obj.selectedIndex].innerText;
}
}
js取复选框选中的text
function selectoppositeCatagory(obj){
// alert(obj.nextSibling.innerText);
var box = document.all("oppositeCatagorycb");//将这个复选框声明成一个对象
var num = box.length; //得到checkbox个数
// alert(num);//显示出复先框的个数是否正确
var itext =""; //new Array();
var ivalue ="";
for(var i=0;i<num;i++){
if(box[i].checked){
itext+=box[i].nextSibling.innerText+",";
ivalue+=box[i].value+",";
}}
itext = itext.substring(0,itext.lastIndexOf(","));
ivalue = ivalue.substring(0,ivalue.lastIndexOf(","));
alert(itext);
alert(ivalue);
var recordCur = ds.getCurrent();
alert(recordCur.get("oppositeCatagory"));
}
本文介绍使用JavaScript来获取HTML中下拉列表的当前选项值及文本,以及如何遍历并获取所有被选中的复选框的值及文本。通过实际代码示例,展示了如何在网页上实现这些常见功能。

被折叠的 条评论
为什么被折叠?



