title: JQuery: How to get selected radio button value?
body: <p>How do I default the value of a non-selected radio button to <code>0</code>?</p>
  
  <p>I have the following HTML:</p>
  
  <pre><code>&lt;input type="radio" name="myradiobutton" value="1" /&gt;1
  &lt;input type="radio" name="myradiobutton" value="2" /&gt;2
  &lt;input type="radio" name="myradiobutton" value="3" /&gt;3
  </code></pre>
  
  <p>And I have the following code to get the value of the <strong>selected</strong> radio button</p>
  
  <pre><code>var radio_button_value $('input[name=myradiobutton]:radio').click(function() {var value = $(this).val();});
  </code></pre>
  
  <p>Problem is, I want to default the value of <code>radio_button_value</code> to <code>0</code> in the event <strong>nothing</strong> is selected. How do I do that?</p>
  
  <p>I basically want to do the pseduo-code below (but this doesn't work)</p>
  
  <pre><code>var radio_button_value $('input[name=myradiobutton]:radio').click(function() { 
  if set
    return $(this).val();
  else
    return 0;
  });
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>There appears to be confusion on what I'm asking for.</p>
  
  <p>What I want to do when the page loads (before a user has had a chance to even select a radio button), I want a function that will return 0 for the radio button value.</p>
  
  <p>Then, once a user selected a radio button, that SAME function will return the selected value of the radio button.</p>
  
  <p>Make sense?</p>