出于某种原因,我无法弄清楚如何反过来做到这一点。我想要做的是有一个下拉菜单,其中有4个选项以及选择状态,当您选择最后一个选项(免除)时,我希望它灰显并禁用里程表读数。并且不再提示说它已经被要求了。出于某种原因,这样可以解除相反的解锁文本框,并禁用其他所有内容的文本框。
<cfselect
name="ostatus"
id="ostatus"
required="yes"
onchange="oreading.disabled=(b=(selectedIndex!=4));b||oreading.focus()"
message="Please select odometer status."
>
<option value="">Select Status</option>
<option value="Actual Mileage">Actual Mileage</option>
<option value="Mileage Exceeds Mechanical Limits">Mileage Exceeds Mechanical Limits</option>
<option value="Not Actual Mileage">Not Actual Mileage</option>
<option value="Exempt">Exempt</option>
</cfselect>
<label for="oreading"> Reading:</label>
<cfinput
type="text"
name="oreading"
id="oreading"
validateat="onSubmit"
validate="noblanks"
required="yes"
message="Please enter odometer reading."
value="#form.oreading#"
onfocus="this.select()"
disabled="disabled"
>
答案 0 :(得分:0)
对于任何想要如何做到这一点的人来说,这就是我想到的!
<script language="javascript">
function dis_able()
{
if(document.form.ostatus.value != 'Others')
document.form.oreading.disabled=0;
else
document.form.oreading.disabled=1;
}
</script>
<cfselect
name="ostatus"
id="ostatus"
required="yes"
message="Please select odometer status."
size="1"
onChange="dis_able()"
>
<option value="">Select Status</option>
<option value="Actual Mileage">Actual Mileage</option>
<option value="Mileage Exceeds Mechanical Limits">Mileage Exceeds Mechanical Limits</option>
<option value="Not Actual Mileage">Not Actual Mileage</option>
<option value="Others">Exempt</option>
</cfselect>
<label for="oreading"> Reading:</label>
<cfinput
type="text"
name="oreading"
id="oreading"
validateat="onSubmit"
validate="noblanks"
required="yes"
message="Please enter odometer reading."
value="#form.oreading#"
onfocus="this.select()"
>