---
title: "js取得下拉列表、复选框的value及text"
author: "robinrain"
date: "2013-05-15T15:28:57Z"
tags: []
categories: ["Web前端"]
slug: "js-value-text"
draft: false
lastmod: "2013-05-15T15:28:57Z"
id: 1869798
url: "https://robinrain.iteye.com/blog/1869798"
---

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"));
}
```