菜鸟求助
我想当我下拉框选择不同时,文本框前面的值改变,它label的值就是不变。
function selectss() {
var params1=document.getElementById("params1");
var params2=document.getElementById("params2");
var a = document.getElementById("eName");
a.options[a.selectedIndex].selected == true;
//alert(a.options[a.selectedIndex].value)
if (a.options[a.selectedIndex].value=="ticket"){
params1.style.display = "";
params1.label=="车票数量";
}
else if (a.options[a.selectedIndex].value == "question"){
params1.style.display = "";
params2.style.display = ""
}
else if(a.options[a.selectedIndex].value == "friend"){
params1.style.display = "";
params1.label="好友个数";
}
else{
params1.style.display = "none";
params2.style.display = "none"
}
}
</script>
<tr class="prop" id="params1" style="display:none">
<td valign="top" class="name">
<label for="params1"><g:message code="gameTask.params1.label" default="Params1"/></label>
</td>
<td valign="top" class="value ${hasErrors(bean: gameTaskInstance, field: 'params1', 'errors')}">
<g:textField name="params1" value="${fieldValue(bean: gameTaskInstance, field: 'params1')}"/>
</td>
</tr>
<tr id="params2" class="prop" style="display:none">
<td valign="top" class="name">
<label for="params2"><g:message code="gameTask.params2.label" default="Params2"/></label>
</td>
<td valign="top" class="value ${hasErrors(bean: gameTaskInstance, field: 'params2', 'errors')}">
<g:textField name="params2" value="${fieldValue(bean: gameTaskInstance, field: 'params2')}"/>
</td>
</tr>
------解决方案--------------------
ID名设置为params1,params2试试