views:

38

answers:

3

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);" 
      runat="server" type="checkbox" />
   </div>
</HeaderTemplate>
A: 

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/

samrockon
oh so your saying just add null for my own refference? I was more looking for a visual clue. Because I have a grid with some checked and some unchecked check boxes. And this one in the header can be used to toggle all the other ones. So I wanted a null state to signal they there are some checked and non-checked.
kralco626
so use "disabled" - its standard html property, and for example on first click remove property. or if you want to be able to check "unchecked", to check\uncheck all - you can add additional field which will be displayed before all boxed checked\unchecked.
samrockon
if you want just one checkbox use http://www.blueshoes.org/en/javascript/checkbox/
samrockon
+2  A: 

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.

Mike Hofer
+2  A: 

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)
Palantir