javascript - Need a way to integrate an Invert function(Check All/Uncheck All) through radio buttons - for the Checkbox group -
javascript - Need a way to integrate an Invert function(Check All/Uncheck All) through radio buttons - for the Checkbox group -
am relatively new doing here. putting stuff find here , other open resources.
the problem having - current setup person can take radio button , check couple boxes , goto other radio button alternative , take boxes under that. trying checkboxes checked when selects radion alternative , uncheckall when person chooses alternative on radio button group.
so if select alternative 'a' under 'general' , goto 'detailed' - 'a' should unchecked.
heres code using in jfiddle
html:
<div id="radiowidget"> <label><input type="radio" name="chkboxs" value="general" />general clean</label> <label><input type="radio" name="chkboxs" value="detailed" />detailed clean</label> <label><input type="radio" name="chkboxs" value="commercial" />commercial clean</label> </div> <div id="general" class="desc"> <p class="maintextblue">general <label><input type="checkbox" name="generaloptn[]" value="a" />a</label> <label><input type="checkbox" name="generaloptn[]" value="b" />b</label> </p> </div> <div id="detailed" class="desc"> <p class="maintextblue">detailed <label><input type="checkbox" name="detailedoptn[]" value="a" />a</label> <label><input type="checkbox" name="detailedoptn[]" value="b" />b</label> </p> </div> <div id="commercial" class="desc"> <p class="maintextblue">commercial <label><input type="checkbox" name="commercialoptn[]" value="a" />a</label> <label><input type="checkbox" name="commercialoptn[]" value="b" />b</label> </p> </div>
jscript:
$(document).ready(function() { $("div.desc").hide(); $("input[name$='chkboxs']").click(function() { var test = $(this).val(); $("div.desc").hide(); $("#" + test).show(); }); });
this piece of script found inverts checkbox state. not sure how integrate radio button. snippet working off onclick() fn button.
$("a[href='#invert_selection']").click( function() { $("#" + $(this).attr('rel') + " input[type='checkbox']").each( function() { $(this).attr('checked', !$(this).attr('checked')); }); homecoming false; });
any help much appreciated...
this requires add together ids input fields... work. if want command multiple input fields can uses classes to..
class="lang-js prettyprint-override">jquery("#generala").click(function(){ if(jquery(this).is(':checked')){ // checked stuff if want }else{ // mot checked uncheck checkbox id of #detaileda jquery('#detaileda').prop('checked', false); } homecoming false; });
javascript jquery html checkbox radio-button
Comments
Post a Comment