Note that there are some explanatory texts on larger screens.

plurals
  1. POActive radio button with jquery
    primarykey
    data
    text
    <p>I used all of the helpful answers on this site to try to build a jquery script to select radio buttons, but for some reason they don't work. Am I doing something wrong? For the sake of simplicity I've started back from square one. </p> <p>I've attached the format that the php-generated form produces below. I tried multiple browsers, but was unable to get any button to select anything. Is there some complexity I'm not taking into account? The page is a .php page, and the form is generated in php.</p> <p>Sorry for the basic question -- any help would be greatly appreciated. Not sure if it's relevant, but I want these buttons to work on mobile as well as various browsers.</p> <p>Form Code:</p> <pre><code> &lt;form class="form-horizontal" method="get" action="submit.php" name="form"&gt; &lt;div class="control-group"&gt; &lt;div class="row-fluid"&gt; &lt;div class="span2"&gt;&lt;/div&gt; &lt;div class="span8"&gt; &lt;label class = "control-label" for="input1"&gt; foreign policy &lt;/label&gt; &lt;div class="controls"&gt; &lt;label class="checkbox inline"&gt;&lt;input type="radio" name="group1" id="1_l" value="1_l"&gt; Liberal&lt;/label&gt; &lt;label class="checkbox inline"&gt;&lt;input type="radio" name="group1" id="1_m" value="1_m"&gt; Moderate&lt;/label&gt; &lt;label class="checkbox inline"&gt;&lt;input type="radio" name="group1" id="1_c" value="1_c"&gt; Conservative&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row-fluid"&gt; &lt;div class="span2"&gt;&lt;/div&gt; &lt;div class="span8"&gt; &lt;br&gt; &lt;center&gt;&lt;button type="submit" class="btn btn-danger btn-large"&gt;Generate&lt;/button&gt;&lt;/center&gt; &lt;/div&gt; &lt;div class="span2"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Jquery Code:</p> <pre><code>$('button').click( function() { $('#1_l').attr('checked', true); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    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