How do i change this code so that when a certain date is entered it goes to URL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daved Nconfused

    #1

    How do i change this code so that when a certain date is entered it goes to URL?

    I found this code and would like to make it so that if a person is checking availability for something, when the correct date is selected, it goes to a URL. Example, click DEC. 18 2010 and it goes to one URL, Dec.19 2010 and it goes to another. or Dec. 18 2011 and it goes to another. I dont understand how to correlate all that. any help would be much appreciated!

    [code=html]
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>


    <script>
    //to check leap year
    function checkleapyear(d atea)
    {
    datea = parseInt(datea) ;

    if(datea%4 == 0)
    {
    if(datea%100 != 0)
    {
    return true;
    }
    else
    {
    if(datea%400 == 0)
    return true;
    else
    return false;
    }
    }
    return false;
    }
    //to populate drop drow boxex with the current month and date
    function populateYearSel ect()
    {
    d = new Date();
    curr_year = d.getFullYear() ;
    curr_month=d.ge tMonth();

    document.getEle mentById('month ').options[curr_month].selected=true;
    for(i = 0; i < 3; i++)
    {
    document.getEle mentById('year' ).options[i] = new Option(curr_yea r-i,curr_year-i);
    }


    if(curr_month== 0 || curr_month==2 ||curr_month==4 || curr_month==6 || curr_month==7 || curr_month==9 || curr_month===11 )
    {
    for(i=0;i<=30;i ++)

    document.getEle mentById('day') .options[i] = new Option(i+1,i+1) ;

    }

    else if(curr_month== 3 || curr_month==5 ||curr_month==8 || curr_month==10)
    {
    for(i=0;i<=29;i ++)

    document.getEle mentById('day') .options[i] = new Option(i+1,i+1) ;


    }

    if(curr_month== 1)
    {
    var year=document.g etElementById(' year').value;


    if(checkleapyea r(year))
    { for(i=0;i<=28;i ++)
    document.getEle mentById('day') .options[i] = new Option(i+1,i+1) ; }
    else
    { for(i=0;i<=27;i ++)
    document.getEle mentById('day') .options[i] = new Option(i+1,i+1) ;}

    }

    }



    </script>

    <body onLoad="populat eYearSelect()">


    <select name="year" id="year" >
    </select>

    <select name="month" id="month">
    <option value=01>JAN</option>
    <option value=02>FEB</option>
    <option value=03>MAR</option>
    <option value=04>APR</option>
    <option value=05>MAY</option>
    <option value=06>JUN</option>
    <option value=07>JUL</option>
    <option value=08>AUG</option>
    <option value=09>SEP</option>
    <option value=10>OCT</option>
    <option value=11>NOV</option>
    <option value=12>DEC</option>
    </select>

    <select name="day" id="day">
    </select>

    </body>



    </html>
    [/code]
    Last edited by Atli; Nov 6 '10, 11:22 AM. Reason: Fixed the [code] tags.
  • TonyBoy
    New Member
    • Nov 2010
    • 6

    #2
    Well, you could send the form as GET and it would be like page?year=2010& month=JAN&day=1, for example.

    I don't know how you'll be using the data afterward so I can't help much.

    But this is a good start:

    Code:
    <body onLoad="populateYearSelect()">
    
    
    [B]<form action="" method="GET">[/B]
     
    <select name="year" id="year" >
    </select>
     
    <select name="month" id="month">
    <option value=01>JAN</option>
    <option value=02>FEB</option>
    <option value=03>MAR</option>
    <option value=04>APR</option>
    <option value=05>MAY</option>
    <option value=06>JUN</option>
    <option value=07>JUL</option>
    <option value=08>AUG</option>
    <option value=09>SEP</option>
    <option value=10>OCT</option>
    <option value=11>NOV</option>
    <option value=12>DEC</option>
    </select>
     
    <select name="day" id="day">
    </select>
    
    [B]<input type="submit" />
    </form>[/B]
    </body>
    Again, what are you going to do next? There are other ways of doing what you asked, I don't know what's the best for you.

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      This must be done with javascript so this thread should be moved to that board.

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        It has been moved.

        Regards,

        Jeff

        Comment

        Working...