React Checkbox not sending onChange

TLDR: Use defaultChecked instead of checked, working jsbin. Trying to setup a simple checkbox that will cross out its label text when it is checked. For some reason handleChange is not getting fired when I use the component. Can anyone explain what I’m doing wrong? var CrossoutCheckbox = React.createClass({ getInitialState: function () { return { … Read more

How to stop event bubbling on checkbox click

I have a checkbox that I want to perform some Ajax action on the click event, however the checkbox is also inside a container with it’s own click behaviour that I don’t want to run when the checkbox is clicked. This sample illustrates what I want to do: $(document).ready(function() { $(‘#container’).addClass(‘hidden’); $(‘#header’).click(function() { if ($(‘#container’).hasClass(‘hidden’)) … Read more

Using the HTML5 “required” attribute for a group of checkboxes?

When using the newer browsers that support HTML5 (FireFox 4 for example); and a form field has the attribute required=’required’; and the form field is empty/blank; and the submit button is clicked; the browsers detects that the “required” field is empty and does not submit the form; instead browser shows a hint asking the user … Read more

Find all unchecked checkboxes in jQuery

I have a list of checkboxes: <input type=”checkbox” name=”answer” id=”id_1′ value=”1″ /> <input type=”checkbox” name=”answer” id=”id_2′ value=”2″ /> … <input type=”checkbox” name=”answer” id=”id_n’ value=”n” /> I can collect all the values of checked checkboxes; my question is how can get all the values of unchecked checkboxes? I tried: $(“input:unchecked”).val(); to get an unchecked checkbox’s value, … Read more

Get the value of checked checkbox?

So I’ve got code that looks like this: <input class=”messageCheckbox” type=”checkbox” value=”3″ name=”mailId[]”> <input class=”messageCheckbox” type=”checkbox” value=”1″ name=”mailId[]”> I just need Javascript to get the value of whatever checkbox is currently checked. EDIT: To add, there will only be ONE checked box. 13 Answers 13

How to set default Checked in checkbox ReactJS?

I’m having trouble to update the checkbox state after it’s assigned with default value checked=”checked” in React. var rCheck = React.createElement(‘input’, { type: ‘checkbox’, checked: ‘checked’, value: true }, ‘Check here’); After assigning checked=”checked”, I cannot interact the checkbox state by clicking to uncheck/check. 18 Answers 18

How to retrieve checkboxes values in jQuery

How to use jQuery to get the checked checkboxes values, and put it into a textarea immediately? Just like this code: <html> <head> </head> <body> <div id=”c_b”> <input type=”checkbox” value=”one_name” checked> <input type=”checkbox” value=”one_name1″> <input type=”checkbox” value=”one_name2″> </div> <textarea id=”t”></textarea> </body> </html> If the id=”c_d” is updated by Ajax, the below of altCognito’s code doesn’t … Read more