Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Date picker jquery getdate not working

    I have problem in the getdate function in jquery datepicker I tried it but not working. I tried the code to alert when select the date but there is no alert. This is the code
    Code:
    <script src="jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery.datepick.css">
    <script type="text/javascript" src="jquery.plugin.js"></script>
    <script type="text/javascript" src="jquery.datepick.js"></script>
    <script src="jquery.chained.min.js"></script>
    <script>
    $(function () {
    $('#popupDatepicker').datepick({dateFormat: 'yyyy-mm-dd'});
    $('#inlineDatepicker').datepick({onSelect: showDate});
    $("#popupDatepicker").datepicker(
    {
    onSelect: function()
    { 
    var dateObject = $(this).datepicker('getDate'); 
    alert(dateObject);
    }
    });
    });
    function showDate(date) {
    alert('The date chosen is ' + date);
    }
    </script>
    <table>
    <tr>
    <td>Birth date:</td>
    <td>
    <input type='date' id='popupDatepicker' size='15' name='birth_day'>
    </td>
    <td>Retirement date:</td>
    <td>
    <input type='text' size='15' id='retirement_date' name='retirement_date'>
    </td>
    </tr>
    </table>
    also I want hint about code to count 65 years from the selected birthdate and give me the retirement date.
    Thanks in Advance

  • #2
    New Coder
    Join Date
    Sep 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Now the alert code is working but I have two problems in this code using jquery datepicker (first is alert the getdate method with time but I need the date only in format(yyyy-mm-dd)) the second problem I need to get the selected date into the textbox but it gives me error
    Code:
    <script src="jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery.datepick.css"> 
    <script type="text/javascript" src="jquery.plugin.js"></script> 
    <script type="text/javascript" src="jquery.datepick.js"></script>
    <script src="jquery.chained.min.js"></script>
    <script>
    $(document).ready(function(){
    $('#popupDatepicker').datepick({
    dateFormat: 'yyyy-mm-dd',
    onSelect: function(){
    var fullDate = $('#popupDatepicker').datepick('getDate');   
    document.getElementByID('maach_year').value=fullDate;             
    alert (fullDate);
    }
    });
    });
    </script>
    <form action='".$server['PHP_SELF']."' method='post'>
    <table>
    <tr><td>Birth Date:</td><td><input type='date' id='popupDatepicker' size='15' name='birth_day'></td>
     <td>Retirement Date:</td><td><input type='text' size='15' id='maach_year' name='maach_year' ></td></tr> 
    <input type='submit'/><br>
    </table> 
    </form>
    I want also if I can add 65 to years that user select in the birth date, put it in the retirement textbox Thanks in Advance
    Last edited by hassanab; 07-15-2014 at 02:34 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •