Page 1 of 1

How to create a calendar for registration like on facebook

Posted: Mon Feb 13, 2012 5:15 am
by lovelf
See that facebook has a calendar for registration that updates the select elements based on the selected dates - per month and year

How to using an existing calendar trigger the date from select elements and update the select elements, for example if February is chosen update the day select to only 28 days, and if in a particular year February has 29 days like on this year update it to 29 days only, the same for months that have 30 or 31 days.

Thanks

So I made this code:

Code: Select all

<script type="text/javascript">
function update_dates(){
var myval=$("#month option:selected").text();
var myval2=$("#day option:selected").val();
if(myval=='Feb'){
document.getElementById('day').innerHTML='<option value="-1">Day:</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option>';
alert(myval2);
$("#day option[value='myval2']").select();

}


}
</script>
Now at the very end I want to select the previous value that was selected before reformatting the select with $("#day option[value='myval2']").select(); but of course that doesn't work, what would be the proper syntax?