jquery - Radio button condition to set a value -


i have 3 radio buttons[ 1day, 1week, 1month ], 1day selected. have required starton , expireon values in hidden field. based on user selection have update starton , expireon values span tag. here starton value same 3 selection, expireon values change based on radio button selection. can 1 me here complete this.

html code:

<body>     <input type="hidden" id="starton" value="01/01/2013" />     <input type="hidden" id="expireday" value="01/01/2013" />     <input type="hidden" id="expireweek" value="01/07/2013">     <input type="hidden" id="expiremonth" value="01/31/2012" />     <input type="radio" id="packageamt1" name="packageamt" checked="checked">1 day</input>     <input type="radio" id="packageamt2" name="packageamt">1 week</input>     <input type="radio" id="packageamt3" name="packageamt">1 month</input>     <br/>start on<span id="startonvalue" /></span>     <br/>expire on<span id="expireonvalue" /></span> </body>  jquery code:  $(document).ready(function () {     var starton = $('#starton').val()     var expireday = $('#expireday').val()     var expireweek = $('#expireweek').val()     var expiremonth = $('#expiremonth').val()     $('#startonvalue').text(starton);     $('#expireonvalue').text(expireday);     $('input[type=radio]').change(function () {      }); }); 

you

http://jsfiddle.net/shhdf/

html

<input type="hidden" id="starton" value="01/01/2013"/>         <input type="hidden" id="expireday" value="01/01/2013"/>          <input type="hidden" id="expireweek" value="01/07/2013">         <input type="hidden" id="expiremonth" value="01/31/2012"/>          <input type="radio" id="packageamt1" value="1"  name="packageamt" checked="checked">1 day</input>         <input type="radio" id="packageamt2" value="2" name="packageamt">1 week</input>         <input type="radio" id="packageamt3" value="3" name="packageamt">1 month</input><br/>          start on<span id="startonvalue" /></span><br/>         expire on<span id="expireonvalue" /></span> 

jquery

 var starton = $('#starton').val()             var expireday = $('#expireday').val()             var expireweek = $('#expireweek').val()             var expiremonth = $('#expiremonth').val()             $('#startonvalue').text(starton);             $('#expireonvalue').text(expireday);          $('input[type=radio]').change(function()         {             var value_radio = $(this).val();              if(value_radio == 1){                  $('#expireonvalue').html($('#expireday').val());              }             if(value_radio == 2){                  $('#expireonvalue').html($('#expireweek').val());              }             if(value_radio == 3){                  $('#expireonvalue').html($('#expiremonth').val());              }          }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -