获取下拉框的value和值

时间:2024-04-10 14:34:34

jsp:

<td class="formItem_content">
<select name="label" id = "label" style="height:30px">
<option value="" id='-1'>--请选择--</option>
</select>
</td>

js:

function labelCascade(){
$.ajax({
 url:"admin/dianliang/gongyong/label/select/",
 data:encodeURI(
)
 ,
 type:"post",
 success:function(data){
 var resultList = data.resultList;
 var options = "";

 for(var i = 0 ;i<resultList.length;i++ ){
 var obj = resultList[i];
 options+="<option value='"+obj.id+"'>"+obj.label_name+"</option>";
}
 $("#label").empty().append(options);
},
error:function(){
 alert("error");
}
});
}

var label_id= $.trim($('#label option:selected',iframe.document).val());
var label_name = $.trim($('#label option:selected',iframe.document).text());