在html中启用或禁用复选框 [英] enable or disable checkbox in html

查看:141
本文介绍了在html中启用或禁用复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



code -



<$ p

我想在表格的行中根据条件启用或禁用复选框。 $ p> < td>< input type =checkboxname =repriseCheckBoxdisabled = {checkStat == 1? true:false} />< / td>

如果checkStat = 1,需要禁用复选框,否则保持启用状态。



这不起作用。它禁用所有的复选框。
有何建议?

解决方案

如果您指定禁用属性,那么你给它的值必须是 disabled 。 (在HTML 5中,除了属性值之外,您可以忽略所有内容,在HTML 4中,除了属性名称外,您可以忽略所有内容。)



如果您不想控制被禁用,则根本不指定该属性。



禁用:

 < input type =复选框已禁用> 
< input type =checkboxdisabled =disabled>

启用:

 < input type =checkbox> 

无效(但通常会将错误恢复为被禁用状态):

 < input type =checkboxdisabled =1> 
< input type =checkboxdisabled =true>
< input type =checkboxdisabled =false>

所以,如果不知道您的模板语言,我想您正在寻找:

 < td>< input type =checkboxname =repriseCheckBox{checkStat == 1? disabled:} />< / td> 


I want to enable or disable checkbox in table's row on basis of condition.

code -

<td><input type="checkbox" name="repriseCheckBox" disabled={checkStat == 1 ? true : false}/></td>

if checkStat = 1, need to disable checkbox else keep it enable.

It's not working. It disabling all the checkboxes. Any suggestions ?

解决方案

If you specify the disabled attribute then the value you give it must be disabled. (In HTML 5 you may leave off everything except the attribute value. In HTML 4 you may leave off everything except the attribute name.)

If you do not want the control to be disabled then do not specify the attribute at all.

Disabled:

<input type="checkbox" disabled>
<input type="checkbox" disabled="disabled">

Enabled:

<input type="checkbox">

Invalid (but usually error recovered to be treated as disabled):

<input type="checkbox" disabled="1">
<input type="checkbox" disabled="true">
<input type="checkbox" disabled="false">

So, without knowing your template language, I guess you are looking for:

<td><input type="checkbox" name="repriseCheckBox" {checkStat == 1 ? disabled : }/></td>

这篇关于在html中启用或禁用复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆