function selectType(keytypeTem){
//给单选按钮赋值
if (null == keytypeTem || "" == keytypeTem) {
$(‘input:radio:first‘).attr(‘checked‘, ‘checked‘);
} else if(1 == keytypeTem){
$(‘input:radio:first‘).attr(‘checked‘, ‘checked‘);
}else{
$(‘input:radio:last‘).attr(‘checked‘, ‘checked‘);
}
var selObj = $("#container");
//selObj.remove(); //移除整个option
selObj.empty();//清空option的值
var value1="";
var text1="请选择证书";
selObj.append("<option value=‘"+value1+"‘>"+text1+"</option>");
//动态添加option
//遍历struts的集合类
<s:iterator value="certList" id="item">
if( keytypeTem == ‘<s:property value="#item.keytype" />‘){
var value=‘<s:property value="#item.container" />‘;
var text=‘<s:property value="#item.subjectname" />‘;
//alert(‘<s:property value="cert.subjectname"/>‘);
if(text == ‘<s:property value="cert.subjectname"/>‘){
selObj.append("<option value=‘"+value+"‘ selected>"+text+"</option>");
//动态添加option并默认选中
} else {
selObj.append("<option value=‘"+value+"‘>"+text+"</option>");
}
}
</s:iterator>
}
html代码为:
<select id="container" name="container" style="width: 160;">
<option value="">
请选择证书
</option>
</select>
function test(){
var obj = {a:1,b:2,c:3}
for(var s in obj){
alert(obj[s]);
}
}
原文:http://blog.csdn.net/wzyzzu/article/details/46315095