Uncheck a checkbox and another checkbox will untick
You can make it like :
<form id="test" action="#" method="post">
<div>
<input type="checkbox" name="check" id="check"/>
</div>
<div>
<input type="checkbox" name="check2" id="check2"/>
</div>
</form>
document.getElementById('check').onclick = function() {
if (!this.checked) {
document.getElementById("check2").checked = false;
} else {
// other logic ...
}};
Test it online on jsfiddle : https://jsfiddle.net/3dtq0w8x/
Check or uncheck checkbox using another checkbox using kivy
You are getting the error from this line:
self.only_def_act.active(False)
which is trying to call the CheckBox
active
attribute (which is a BooleanProperty
) as if it were a method.
Perhaps you meant:
self.only_def_act.active = False
Uncheck a checkbox when another is checked
BUT when i am pressing Test again, the test checkbox is refusing to
chech unless i manually uncheck notTest.
It is because when you press again, you didn't check which checkbox you have clicked on. You simply unchecked a checked-checkbox.
Try this simple approach
var allIds = [ "choice_31_3_1", "choice_31_3_2" ];function uncheck( event ) { var id = event.target.id; allIds.forEach( function( id ){ if ( id != event.target.id ) { document.getElementById( id ).checked = false; } });}
jQuery("#choice_31_3_1").click(uncheck);jQuery("#choice_31_3_2").click(uncheck);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name="input_3.1" value="Test" id="choice_31_3_1" type="checkbox"><label for="choice_31_3_1" id="label_31_3_1">Test</label><input name="input_3.2" value="notTest" id="choice_31_3_2" type="checkbox"><label for="choice_31_3_2" id="label_31_3_2">notTest</label>
Unchecking a Checkbox will uncheck other checkboxes in a table
Pure Javascript solution (no framework is tagged).
Demo
var table = document.getElementById("mytable");
var checkbox;
for(var i=0; i<table.rows.length; i++){
checkbox = table.rows[i].cells[1].getElementsByTagName("input")[0];
checkbox.onchange = function(){
var others = this.parentNode.parentNode.cells[2].getElementsByTagName("input");
for(var j=0; j<others.length; j++){
others[j].checked = this.checked;
}
}
}
Uncheck a checkbox if another checked with javascript
Well you should use radio buttons, but some people like the look of checkboxes, so this should take care of it. I've added a common class to your inputs:
function cbChange(obj) {
var cbs = document.getElementsByClassName("cb");
for (var i = 0; i < cbs.length; i++) {
cbs[i].checked = false;
}
obj.checked = true;
}
Demo: http://jsfiddle.net/5uUjj/
A row is removed when uncheck a checkbox after checked all the check boxes
In OnCheckBoxchangeAll(data)
you need to change as follows:
if (this.checkedAll === true) {
this.selectedItems = [...data];
}
So the 2 arrays do not point to the same memory address but are managed as 2 separate arrays.
Otherwise, the following:
this.selectedItems.splice(this.selectedItems.findIndex(x => x.id === data.id) , 1);
causes the original data
to change as well.
Uncheck other checkbox on checked flutter
You can take change state of another variables on click of checkbox in onChanged() method
and assign that value to checkbox widget such as below:
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: MyHomePage(),
));
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool valMonday = false;
bool valTuesday = false;
bool valWednesday = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Group Checkboxes"),
centerTitle: true,
),
body: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// [Monday] checkbox
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Monday"),
Checkbox(
value: valMonday,
onChanged: (bool value) {
setState(() {
valMonday = value;
valTuesday = false;
valWednesday = false;
});
},
),
],
),
// [Tuesday] checkbox
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Tuesday"),
Checkbox(
value: valTuesday,
onChanged: (bool value) {
setState(() {
valTuesday = value;
valMonday = false;
valWednesday = false;
});
},
),
],
),
// [Wednesday] checkbox
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Wednesday"),
Checkbox(
value: valWednesday,
onChanged: (bool value) {
setState(() {
valWednesday = value;
valMonday = false;
valTuesday = false;
});
},
),
],
),
],
),
));
}
}
How do I check/uncheck all checkboxes with a button using jQuery?
Try this one :
$(document).ready(function(){
$('.check:button').toggle(function(){
$('input:checkbox').attr('checked','checked');
$(this).val('uncheck all');
},function(){
$('input:checkbox').removeAttr('checked');
$(this).val('check all');
})
})
DEMO
Related Topics
Javascript Sum and Group by of Json Data
Typescript Property Does Not Exist on Type {}
Discord.Js Ban/Kick Commands Available to All Users. How to Fix This
Jquery - Ajax Returning Error 500 on Some Posts
Textarea With Initial Auto Height by Content With Pure CSS
Onclick Table Row With Onclick Button and Bootstrap Modal Inside
How to Download a File With Node.Js (Without Using Third-Party Libraries)
How to Redirect to Another Component Onsubmit Search
How to Determine Server Disconnection from Signalr Client
React-Native React-Navigation Undefined Is Not an Object (Evaluating 'S.Value.Startswith')
Allow Only One Checked Checkbox, Angular Best Practice.
How to Wait for Element to Disappear in Cypress
Blob Download Is Not Working in Ie
Chat Box, Auto Scroll to Bottom
Possible to Detect If a User Has Multiple Tabs of Your Site Open