CheckBox functionality

  • Bryan

    Bryan - 2004-01-26


    I've been using the asp version of the template system for a couple of weeks now and I have a why question with the way setfields/setcheckbox works on check boxes.

    First there is a mismatch between the comments on the setfields and the actual behavior of the function.

    Currently you need an exact match of name and value to mark it checked.  I can see this would be usefull if you had a group of checkboxes with the same name and wanted to select one based on value. 

    The other apporach that you probalby originally took (based on the comments of the setfield) was:
    'For checkbox, if the passed value is boolean true, the checkbox value will be 'True' and checked.
    'if the passed value is boolean false, checked will be cleared and value set to 'True'
    'if anything else is passed, the value will be set the the value passed and check will be set.

    Checking it based on a boolean value would make since if you had unique named checkboxes and were pulling data from a boolean in a database.  Also there is the special "on" value that gets set if the value is empty or missing and the box is checked. 

    I have modified my copy to set the tag to checked if the passed in value is "true" or "on" as well as when the value matches the defined value.  Obviously this will be a problem if you use checkboxes that are the same name and set one of their values to true or on.

    Just wondering your reason for switching implementations. 


    • Andrew Freese

      Andrew Freese - 2004-03-24

      Hi Bryan,
      Sorry for the delayed reply.
      The truth is I can't remember what the motivation was but I suspect your intuition is correct about wanting to have multiple checkboxes with the same name. I do vaguely remember doing something with an "array" of checks with the same name a long time ago.

      Sorry again for the delay in responding.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks