+ 5

what does value do in this code?

<input type="checkbox" name="gender" value="1" /> Male <br /> <input type="checkbox" name="gender" value="2" /> Female <br /> without value this code is working fine, so why do I use value? one more thing is, nothing happening while I am changing the number of value.

22nd Feb 2018, 2:18 AM
RH Tasin
RH Tasin - avatar
1 Réponse
+ 6
The "value" is useful when you want user's choice. For example: $("input[name=gender]:checked").val() -> returns the value of your checkboxes!
22nd Feb 2018, 2:39 AM
777
777 - avatar