title: Jquery: My onclick function for radio buttons not firing the first time a radio button is clicked
body: <p>I want to ask the user a series of questions whose answers are radio buttons and with each answer update a the html of the  id=creditamount with the variable creditAmount. My code only works after I've clicked the second radio button?  Any ideas why that is happening?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript" src="jquery-1.4.2.js"&gt;&lt;/script&gt;
      &lt;link rel = "stylesheet" type="text/css" href="custom.css" /&gt;
  
      &lt;script&gt;
      var creditAmount;
      $(document).ready(function(){
  
        $("input[name='alive']").live('click', function(){
          $("input").click(function() {
  
          creditAnswer = $(":checked").val(); 
          if (creditAnswer == "Yes")
              {
                  creditAmount = 1000;
              }       
          else if (creditAnswer == "No")
              {
                  creditAmount = 100;
              }       
          else if (creditAnswer == "Both")
              {
                  creditAmount = 5000;
              }       
          $("#creditamount").html(creditAmount);
          });
       });            
        });
        &lt;/script&gt; 
  
      &lt;/head&gt;
      &lt;form&gt;
       &lt;div id="creditlimit"&gt; Credit Limit: &lt;/div&gt;&lt;div id ="creditamount"&gt;0 &lt;/div&gt;
  
      Are you currently alive? 
      &lt;input type="radio" name="alive" value="Yes" /&gt; Yes 
      &lt;input type="radio" name="alive" value="No" /&gt; No 
      &lt;input type="radio" name="alive" value="Both" /&gt; Depends upon the day of the week.
      &lt;/form&gt;
      &lt;/html&gt;
  </code></pre>