codeigniter - How to show future months and dates using php? -
i need add together leave list.it should add together 2 years should show 2014 , 2015 did. problem have show months when select 2014 should not show jan may , if select 2015 should show jan dec.how can populate month based on year
in image showing 2013 please ignore because scheme showing wrong year.
here html code
<table> <tr> <td colspan="3">add leave</td> </tr> <tr> <td width="170" valign="middle" height="40" align="left">date</td> <td width="15" valign="middle" align="left">:</td> <td><select id="frm_day" name="frm_day"> <?php for($i=1;$i<31;$i++) { echo "<option value=".$i.">".$i."</option>"; } ?> </select> </td> <td> <select id="frm_year" name="frm_year"> <option value="<?php echo date("y");?>"><?php echo date("y");?></option> <option value="<?php echo date("y")+1;?>"><?php echo date("y")+1;?></option> </select> </td> <td> <select id="frm_month" name="frm_month"> <option value="<?php echo date("m");?>"><?php echo date("m");?></option> </select> </td> </tr> <tr> <td colspan="3"> <input type="submit" name="submit" id="submit" value="submit" class="submit" /> </td> </tr> </table>
add @ end of <body>
<script type="text/javascript"> var currentmonth = <?php date('m'); ?>; var currentyear = <?php date('y'); ?>; var fulllist = document.getelementbyid('frm_month').innerhtml; function changedyear(obj) { var selectedyear = obj.value, node; if (selectedyear == currentyear) { (var = 1; < currentmonth; i++) { node = document.queryselector('#frm_month option[value='+i+']'); node.parentnode.removechild(node); } } else { document.getelementbyid('frm_month').innerhtml = fulllist; } } </script>
and change:
<select id="frm_year" name="frm_year">
to
<select id="frm_year" name="frm_year" onchange="changedyear(this)">
this remove months not in current year if user selects it. on other year total list restored.
php codeigniter
No comments:
Post a Comment