关于script 的问题在线等
小弟写了个这样的script
<script>
function changelocation()
{
var id=form2.PayKind.value;
if(id== "首期 ")
{
form2.PremNumber.value= "1 ";
form2.PremNumber.readonly= "ture ";
form2.Cvrg.disabled= "false ";
}
else if(id== "补缴首期 ")
{
form2.PremNumber.value= "0 ";
form2.PremNumber.readonly= "ture ";
form2.Cvrg.disabled= "false ";
}
else if(id== "POS ")
{
form2.PremNumber.value= "0 ";
form2.PremNumber.readonly= "true ";
form2.Cvrg.disabled= "true ";
}
}
</script>
form2.Cvrg.disabled= "true ";这一句将一个下拉框置为不可读写。
在我选择POS这个 属性的时候它进行了操作,但是当我回选其他属性的时候,这个不可读写的属性一直保持,怎么样让它只在选择POS属性的情况下才不可读写,其他情况下都可以操作
------解决方案-------------------- <script>
function changelocation()
{
var id=form2.PayKind.value;
if(id== "首期 ")
{
form2.PremNumber.value= "1 ";
form2.Cvrg.disabled=false;
}
else if(id== "补缴首期 ")
{
form2.PremNumber.value= "0 ";
form2.Cvrg.disabled=false;
}
else if(id== "POS ")
{
form2.PremNumber.value= "0 ";
form2.Cvrg.disabled=true;
}
}
</script>
<form name= "form2 ">
<select name= "PayKind " onchange= "changelocation() ">
<option value= "首期 "> 首期 </option>
<option value= "补缴首期 "> 补缴首期 </option>
<option value= "POS "> POS </option>
</select>
<input type= "text " name= "PremNumber " readonly= "readonly "/> <input type= "text " name= "Cvrg "/>
</form>