Difference between revisions of "Allowing Only One Check Box to be Selected"
From SmartWiki
Nancy Sabo (talk | contribs) |
|||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
onclick="onlyonechecked(this)" | onclick="onlyonechecked(this)" | ||
+ | '''NOTE: It is normally better to use a [[Combo Box]] custom field with ''Show as Radio Buttons'' selected''' | ||
− | This can be used for: | + | |
− | * [[Custom Field Type: Select Many – Check Boxes|Select Many - Check Box]] | + | This can be used for: |
− | + | ||
− | * [[Custom Field Type: Select Many – Scrolling Check Box|Select Many - Scrolling Check Box]] | + | * [[Custom Field Type: Select Many – Check Boxes|Select Many - Check Box]] <!-- |
+ | *: and | ||
+ | * [[Custom Field Type: Select Many – Scrolling Check Box|Select Many - Scrolling Check Box]] --> | ||
The [[User|user]] will not be able to select more than a single check box with this code in place. | The [[User|user]] will not be able to select more than a single check box with this code in place. | ||
Line 15: | Line 18: | ||
==Note== | ==Note== | ||
* If using '''onlyonechecked''' on a [[Custom Field Type: Select Many – Check Boxes|Select Many - Check Box]] field and you also want to [[Show/Hide Header]] you should use '''_showhideheader''' instead of '''_showhideheadercheckbox''' | * If using '''onlyonechecked''' on a [[Custom Field Type: Select Many – Check Boxes|Select Many - Check Box]] field and you also want to [[Show/Hide Header]] you should use '''_showhideheader''' instead of '''_showhideheadercheckbox''' | ||
− | + | ||
[[Category: Custom Fields]][[Category:JavaScript]] | [[Category: Custom Fields]][[Category:JavaScript]] |
Latest revision as of 13:40, 22 August 2018
To prevent a user from selecting more than one Check Box for the associated Custom Field, add this code to the HTML Tag section of the Custom Field:
onclick="onlyonechecked(this)"
NOTE: It is normally better to use a Combo Box custom field with Show as Radio Buttons selected
This can be used for:
The user will not be able to select more than a single check box with this code in place.
For a Select One - Combo Box field, the "Show as Radio Buttons" option can be selected to display the field selections as "radio buttons."
Note
- If using onlyonechecked on a Select Many - Check Box field and you also want to Show/Hide Header you should use _showhideheader instead of _showhideheadercheckbox