开发者

show html checkbox as neither checked or non-checked

I have an html checkbox that controls a list of checkboxes. I want this checkbox to display in a sorta "null" state where it is neither true nor false. Is this possible?

<HeaderTemplate>
   <div style="width:90px">
      Toggle:
      <input id="chkAll"  
      onclick="javascript:SelectAllCheckboxes(this);" 
      开发者_JAVA技巧runat="server" type="checkbox" />
   </div>
</HeaderTemplate>


No, a checkbox won't allow a custom third state. You need to find another way to handle it. A few come to my mind:

  • Use a dropdown list with three values, or three radio buttons
  • Use two checkboxes, one for assigned/null, second for checked/unchecked
  • Use an image and javascript to fill a hidden numeric field (it could be a fake checkbox, but it will not match each browser's look and feel and could look weird)


HTML doesn't natively support the notion of a three-state checkbox. You'd have to implement it with a custom control, using a combination of images and text.


no it isn't. but you can add additional property like you have 'runat'.

<input id="chkAll"  
      onclick="javascript:SelectAllCheckboxes(this);" 
      runat="server" type="checkbox" null="true" />

or you can add "disabled" instead of "checked"

here is js plugin that can help you: http://www.blueshoes.org/en/javascript/checkbox/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜