Making sure at least one checkbox is checked

You should avoid having two checkboxes with the same name if you plan to reference them like document.FC.c1. If you have multiple checkboxes named c1 how will the browser know which you are referring to? Here’s a non-jQuery solution to check if any checkboxes on the page are checked. var checkboxes = document.querySelectorAll(‘input[type=”checkbox”]’); var checkedOne … Read more

How to make a control in XAML public in order to be seen in other classes

Using the following XML you can define a control as a public field on the class to be able to access it from other classes: <CheckBox x:Name=”myCheckBox” x:FieldModifier=”public” /> Now you can access the field directly in code: if (win.myCheckBox.IsChecked.Value) { // … } I agree with H.B., though, that using the MVVM pattern is … Read more

jQuery Uniform Checkbox does not (un)check

SIMPLE SOLUTION This is because UniformJs requires that you update your modification on uniform elements if you need to change values on the form dynamically: $(‘#checkbox’).prop(‘checked’,true); $.uniform.update(); Edit If you wish to update the #checkbox only: $(‘#checkbox’).prop(‘checked’,true); $.uniform.update(‘#checkbox’);

Pass values of checkBox to controller action in asp.net mvc4

If a checkbox is checked, then the postback values will contain a key-value pair of the form [InputName]=[InputValue] If a checkbox is not checked, then the posted form contains no reference to the checkbox at all. Knowing this, the following will work: In the markup code: <input id=”responsable” name=”checkResp” value=”true” type=”checkbox” /> And your action … Read more

How to make the checkbox unchecked by default always

No, there is no way in simple HTML. Javascript might be your only solution at this time.. Loop through all inputs in javascript, check if they’re indeed a checkbox and set them to unchecked: var inputs = document.getElementsByTagName(‘input’); for (var i=0; i<inputs.length; i++) { if (inputs[i].type == ‘checkbox’) { inputs[i].checked = false; } } wrap … Read more

jQuery: selecting checked checkbox

The name of the field isn’t foo, it is foo[]. You could use the attributeStartsWith selector: $(“input[name^=’foo’]:checked:enabled”,’#myform’); Ideally, you’d be able to do this: $(“input[name=”foo[]”]:checked:enabled”,’#myform’); But as this answer explains, jQuery uses this to parse the value part of the attr=value condition: ([‘”]*)(.*?)\3|)\s*\] \3 being the group containing the opening quotes, which weirdly are allowed … Read more

Setting ngTrueValue and ngFalseValue to numbers

You can use ngChecked, If the expression is truthy, then special attribute “checked” will be set on the element <input type=”checkbox” ng-model=”checkbox” ng-true-value=”1″ ng-false-value=”0″ ng-checked=”checkbox == 1″ /> And you can use $scope.$watch to convert it to number $scope.$watch(function(){ return $scope.checkbox; }, function(){ $scope.checkbox = Number($scope.checkbox); console.log($scope.checkbox, typeof $scope.checkbox); },true); DEMO

How to prevent firing CheckedChanged event when checking a control programmatically?

I think your way is fine. The other way to do it is remove the EventHandler before the check, and then add it back again after the check. This way eliminates the need for the isFrozen variable. private void btn1_CheckedChanged(object sender, EventArgs e) { btn2.CheckedChanged -= btn2_CheckedChanged; btn2.Checked = false; btn2.CheckedChanged += btn2_CheckedChanged; // Do … Read more