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
    Jun 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    calendar in js or jquery

    Hello, I got the below code working. My question is when I select a month and year, How can I link a page to that?



    That means, if I select Jun 2013, I want page1.html opens, selects Jul 2013, i want page2.html opens.If you help me with one link, I could do the rest myself.

    Do I need to have if else statement here? Like If date = Jun 2013 then
    href = ...

    Please advise.


    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html 
    xmlns
    ="http://www.w3.org/1999/xhtml" 
    xml:lang="en" lang="en"><head>    <script 
    src
    ="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script>    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>    
    <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">    
    <script type="text/javascript">    $(function() 
    {        $('.date-picker').datepicker( 
    {            
    changeMonth: 
    true,            
    changeYear: 
    true,            
    showButtonPanel: 
    true,            
    dateFormat: 'MM 
    yy',            
    onClose: function(dateText, inst) 
    {                
    var month = $("#ui-datepicker-div .ui-datepicker-month 
    :selected").val();                
    var year = $("#ui-datepicker-div .ui-datepicker-year 
    :selected").val();                
    $(this).datepicker('setDate', new Date(year, month, 
    1));            
    },            
    beforeShow : function(input, inst) 
    {                
    if ((datestr = $(this).val()).length > 0) 
    {                    
    year = datestr.substring(datestr.length-4, 
    datestr.length);                    
    month = jQuery.inArray(datestr.substring(0, datestr.length-5), 
    $(this).datepicker('option', 
    'monthNames'));                    
    $(this).datepicker('option', 'defaultDate', new Date(year, month, 
    1));                    
    $(this).datepicker('setDate', new Date(year, month, 
    1));                
    }            
    }        });    
    });    </script>    
    <style>    .ui-datepicker-calendar 
    {        display: 
    none;        }    
    </style></head><body>    <label 
    for="startDate">Date :</label>    <input 
    name="startDate" id="startDate" class="date-picker" 
    /></body></html> 
    Thanks. 

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    I wouldnt name them page1,page2 and so on. I'd name them june2013.html, july2013.html

    then you can do this. ( this is a simple example )

    Code:
    onClose: function(dateText, inst)  
    {                 
    var month = $("#ui-datepicker-div .ui-datepicker-month  
    :selected").val();                 
    var year = $("#ui-datepicker-div .ui-datepicker-year  
    :selected").val();                 
    $(this).datepicker('setDate', new Date(year, month,  
    1)); 
    
    window.open("http://www.mysite.com/"+month+year+".html")
                
    },


  •  

    Posting Permissions

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