jQuery with multiple radio groups, want only 1 group to have "yes" set rest change to "no" -
I need to create it, when a group is set to "yes" then the other group is "no" With the possibility of being set with load as well (not necessarily just one click ()
event
I am unable to click on all the radio ( Which throws an error but submit) but can not know how to set the "0" value to others
I can do things .. Changing / adding classes, changing the ID (although there is not a certain amount of values, it can be dynamically generated from DB between 1 and 10 (or more) addresses in the list)
Here is the html, I can not change the "name" because I do not have the processing on it, only the html output (somehow more styling)
This is not possible to send the price of unchecked radio on the server, so this trick has a hidden field for each radio and instead of the radio / radio for the radio Is sent Please have an idea from the code given shock, it has not been tested.
& lt; Div class = "btn-group" data-toggle = "button" & gt; & Lt; Input type = "hidden" id = "primary-hidden -0" value = "1" name = "address [0] [primary]" /> & Lt; Label class = "btn btn-primary" & gt; & Lt; Input type = "radio" id = "primary-0-1" value = "1" /> Yes & lt; / Labels & gt; & Lt; Label class = "btn btn-primary active" & gt; Input type = "radio" id = "primary -0-0" value = "0" check = "check" /> No & lt; / Labels & gt; & Lt; / Div & gt; & Lt; Div class = "btn-group" data-toggle = "button" & gt; & Lt; Input type = "hidden" id = "primary-hidden -1" value = "1" name = "address [1] [primary]" /> & Lt; Label class = "btn btn-primary active" & gt; & Lt; Input type = "radio" id = "primary-1-1" value = "1" check = "check" /> Yes & lt; / Label & gt; & Lt; Label class = "btn btn-primary" & gt; Input No & lt; / Label & gt; & Lt; / Div & gt; & Lt; Div class = "btn-group" data-toggle = "button" & gt; & Lt; Input type = "hidden" id = "primary-hidden-2" value = "1" name = "address [2] [primary]" /> & Lt; Label class = "btn btn-primary" & gt; & Lt; Input type = "radio" id = "primary -2-1" value = "1" /> Yes & lt; / Labels & gt; & Lt; Label class = "btn btn-primary active" & gt; Input type = "radio" id = "primary -2-0" value = "0" check = "check" /> No & lt; / Labels & gt; & Lt; / Div & gt; $ ("Input [type = radio]: checked"). Each (function () {$ (this) .prevAll ("Input [type = hidden]"). Val ($ (this) .val ());}); $ ("Input [type = radio]"). Change (function () {$ (this) .prevAll ("Input [type = hidden]") Val ($ (this) .val ()); $ ("input [type = radio]: checked" ) .each (.) ($) ($) (This is) .pop ("checked", wrong); $ (this) .prevAll ("input [type = hidden]") .val ($ (this ) .val ());}); });
Comments
Post a Comment