Home › Forums › Quform WordPress › Select other checkboxes with a checkbox in code
- This topic has 4 replies, 2 voices, and was last updated 7 years, 5 months ago by Ally.
- AuthorPosts
- October 13, 2016 at 9:33 pm #20113jerkskiParticipant
Hello, I have a group of checkboxes, but would like each checkbox to preselect a group of checkboxes. For example, when I check checkbox A, it would then automatically check checkboxes 1,2,3. If I check checkbox B, it will check checkboxes 4,5,6.
Is this possible?
October 13, 2016 at 10:11 pm #20114jerkskiParticipantI got the following to work for selecting all checkboxes in a checkbox group. Is there any way I can get it to also deselect the checkboxes as well. iphorm_2_36 is my primary checkbox, and
<script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value = jQuery(this).val();
var $amp = jQuery(‘.iphorm_2_154’);
$amp.each(function () {
{
jQuery(this).prop(‘checked’, true);
}
});
jQuery.uniform.update();
}).change();
});
</script>October 14, 2016 at 3:18 am #20115jerkskiParticipantWell, here is my crack at it… It works, but I think my code is getting confused because it selects the correct group of checkboxes, but then checking or unchecking another box deselected that group. Any tips on how to simplify this?
<script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value1 = jQuery(this).val();
var $amp1 = jQuery(‘.iphorm_2_154’);
$amp1.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value1 == ‘1’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value2 = jQuery(this).val();
var $amp2 = jQuery(‘.iphorm_2_153’);
$amp2.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value2 == ‘2’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value3 = jQuery(this).val();
var $amp3 = jQuery(‘.iphorm_2_155’);
$amp3.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value3 == ‘3’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value4 = jQuery(this).val();
var $amp4 = jQuery(‘.iphorm_2_156’);
$amp4.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value4 == ‘4’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value5 = jQuery(this).val();
var $amp5 = jQuery(‘.iphorm_2_157’);
$amp5.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value5 == ‘5’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value6 = jQuery(this).val();
var $amp6 = jQuery(‘.iphorm_2_158’);
$amp6.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value6 == ‘6’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value7 = jQuery(this).val();
var $amp7 = jQuery(‘.iphorm_2_159’);
$amp7.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value7 == ‘7’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value8 = jQuery(this).val();
var $amp8 = jQuery(‘.iphorm_2_160’);
$amp8.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value8 == ‘8’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value9 = jQuery(this).val();
var $amp9 = jQuery(‘.iphorm_2_161’);
$amp9.each(function () {if(jQuery(‘.iphorm_2_36’).is(“:checked”)&& value9 == ‘9’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value10 = jQuery(this).val();
var $amp10 = jQuery(‘.iphorm_2_162’);
$amp10.each(function () {if(jQuery(‘.iphorm_2_36′).is(“:checked”)&& value10 == ’10’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value11 = jQuery(this).val();
var $amp11 = jQuery(‘.iphorm_2_163’);
$amp11.each(function () {if(jQuery(‘.iphorm_2_36′).is(“:checked”)&& value11 == ’11’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value12 = jQuery(this).val();
var $amp12 = jQuery(‘.iphorm_2_164’);
$amp12.each(function () {if(jQuery(‘.iphorm_2_36′).is(“:checked”)&& value12 == ’12’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script><script>
jQuery(document).ready(function ($) {
jQuery(‘.iphorm_2_36’).click(function(){
var value13 = jQuery(this).val();
var $amp13 = jQuery(‘.iphorm_2_165’);
$amp13.each(function () {if(jQuery(‘.iphorm_2_36′).is(“:checked”)&& value13 == ’13’) {
jQuery(this).prop(‘checked’, true);
} else {
jQuery(this).prop(‘checked’, false);
}
});
jQuery.uniform.update();
}).change();
});
</script>October 14, 2016 at 5:43 am #20116jerkskiParticipantFound a better way!
<script>
jQuery(document).ready(function ($) {
$(‘.iphorm_2_36’).click(function(){var $chkA = $(this),
value1 = $chkA.val(),
chkUnchk = $chkA.is(‘:checked’),
ampX = ”;switch (value1) {
case ‘1’:
ampX = ‘.iphorm_2_154’;
break;
case ‘2’:
ampX = ‘.iphorm_2_153’;
break;
case ‘3’:
default:
ampX = ‘.iphorm_2_155’;
break;
};
$(ampX).each(function () {
$(this).prop(‘checked’, chkUnchk);
});jQuery.uniform.update();
}).change();
});
</script>October 20, 2016 at 2:11 pm #20142AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.