Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  95] [ 3]  / answers: 1 / hits: 25475  / 11 Years ago, tue, july 23, 2013, 12:00:00

We are currently using $('form').serialize() to get all form information



This will return any checkbox values as On or Off.



Is there any way to get a 1/0 or true/false value using this same method?


More From » jquery

 Answers
70

Yes. You can do it by adding a hidden input with the same name as checkbox which value will be submitted if checkbox is unchecked:



<input type=hidden name=option value=false/>
<input type=checkbox name=option value=true/>


It will submit both values if checkbox is checked. But server side will read the latest one (value of checkbox)


[#76805] Monday, July 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mira

Total Points: 460
Total Questions: 108
Total Answers: 99

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
mira questions
;