00问答网
所有问题
用JS怎么给select标签设置动态的默认值?
如题所述
举报该问题
其他回答
第1个回答 推荐于2019-09-26
<select>
<option <% if(staff.getSection()==1){ out.print("selected=''")}%>>1</option>
<option <% if(staff.getSection()==2){ out.print("selected=''")}%>>2</option>
</select>
本回答被网友采纳
相似回答
用JS怎么给select标签设置动态的默认值?
答:
\x0d\x0a>1\x0d\x0a>2\x0d\x0a
用JS怎么给select标签设置动态的默认值?
答:
<select> <option <% if(staff.getSection()==1){ out.print("
selected
=''")}%>>1</option> <option <% if(staff.getSection()==2){ out.print("selected=''")}%>>2</option> </select>
js如何动态为select
赋值
答:
参看下面的例子,假设
select的
id是"selectTest"for (var i=0; i < a_opt.length; i++) { var op = document.createElement("option");op.text = a_opt[i]; //显示值 op.value = i; //value form1.selectTest.add(op);} } ...
高手请进!
js如何
控制
select标签
默认
被选中?
答:
再加个判断,
如果res_id==003 就给option一个属性 selected="selected"。这样就默认选中的
。输出出来应该是这样的 <option value="003" selected="selected">补考</option>
大家正在搜
怎么设置select的默认值
select动态设置默认值
select框设置默认值
select下拉列表设置默认值
js设置select默认选中
select标签默认选择
html5select默认值
select默认值设定
select标签设置名称