Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Keep it simple; Don't use <code>onclick</code> and you don't need <code>submitFunction</code> for the posted code.<br> This should work:<br> <strong><a href="http://jsfiddle.net/vFamB/1/" rel="nofollow">See it in action at jsFiddle</a>.</strong></p> <pre><code>&lt;script type="text/javascript" &gt; $("input.liveRadio1").click (function () { var jThis = $(this); var hiddenValue = jThis.siblings ('input[name="hidden_value"]').val (); var vote = jThis.val (); var dataString = 'vote=' + vote + 'hiddenValue=' + hiddenValue; alert(dataString); }); &lt;/script&gt; &lt;form action="post" name="form1" &gt; &lt;input type=hidden name='hidden_value' value='12345'&gt; &lt;input class="liveRadio1" type='radio' name='vote' value='yes'&gt;Yes &lt;br/&gt; &lt;input class="liveRadio1" type='radio' name='vote' value='no'&gt;No &lt;/form&gt; </code></pre> <p><br> </p> <hr> <h2>Additional answer for the revised question:</h2> <p>The code doesn't work in the standalone file because enough time was not allowed for jQuery, and the DOM, to initialize.</p> <p>The standard way to do that is to use the <code>ready</code> event. Like so:</p> <pre><code>&lt;script type="text/javascript"&gt; function jQueryMain () { $("input.liveRadio1").click(function() { var jThis = $(this); var hiddenValue = jThis.siblings('input[name="hidden_value"]').val(); var vote = jThis.val(); var dataString = 'vote= ' + vote + ', hiddenValue= ' + hiddenValue; alert(dataString); }); } $(document).ready (jQueryMain); &lt;/script&gt; </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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