Note that there are some explanatory texts on larger screens.

plurals
  1. POupdate a set of radio values with jquery or basic javascript
    primarykey
    data
    text
    <p>im pretty new to jquery and bootstrap framework. however, i was trying to use <a href="http://www.bootstrap-switch.org" rel="nofollow noreferrer">bootstrap-switch plugin</a> to create a nice yes / no switch on a set of radiobuttons generated via mysql query (name of the radio as the id of a checkbox).</p> <p>what i did is a nice table with this switch:</p> <p><img src="https://i.stack.imgur.com/t6mg4.png" alt="enter image description here"></p> <p>i did manage to change radio value to yes/no if the switch is toggled with this code:</p> <pre><code>&lt;div class="make-switch radioswitch"&gt; &lt;input type="radio" checked="checked" value="yes" name="00839770708"&gt;&lt;/input&gt; &lt;/div&gt; &lt;div class="make-switch radioswitch"&gt; &lt;input type="radio" value="no" name="00481821213"&gt;&lt;/input&gt; &lt;/div&gt; &lt;div class="make-switch radioswitch"&gt; &lt;input type="radio" checked="checked" value="yes" name="23467894567"&gt;&lt;/input&gt; &lt;/div&gt; etc.. </code></pre> <p>and the jquery javascript called is:</p> <pre><code>&lt;script&gt; $('.radioswitch').on('switch-change',function(e,data){ var$el=$(data.el) ,value=data.value; if(value==true) {alert('value is yes'); // it sets the radio's value with "yes", but it works on a single radio with a given name $("input[type=radio][name=00100190610]").val("yes"); } else{alert('value is no'); // it sets the radio's value with "no", but it works on a single radio with a given name $("input[type=radio][name=00100190610]").val("no");} console.log(e,$el,value); }); &lt;/script&gt; </code></pre> <p>what i want to know is how i can pass a parameter to name selector of checked radio</p> <p>or use another instruction to tell javascript " update radio value where radio name is xxx "</p> <p>thanks in advance and sorry if i explained the problem bad.</p> <p><a href="http://jsfiddle.net/20mark/2T9Fe/8/" rel="nofollow noreferrer">JSFIDDLE EXAMPLE</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload