By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,358 Members | 2,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,358 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  3. <title>New Page 1</title>
  4. </head>
  5.  
  6.  
  7. <script>
  8. //to check leap year
  9. function checkleapyear(datea)
  10. {
  11. datea = parseInt(datea);
  12.  
  13. if(datea%4 == 0)
  14. {
  15. if(datea%100 != 0)
  16. {
  17. return true;
  18. }
  19. else
  20. {
  21. if(datea%400 == 0)
  22. return true;
  23. else
  24. return false;
  25. }
  26. }
  27. return false;
  28. }
  29. //to populate drop drow boxex with the current month and date
  30. function populateYearSelect()
  31. {
  32. d = new Date();
  33. curr_year = d.getFullYear();
  34. curr_month=d.getMonth();
  35.  
  36. document.getElementById('month').options[curr_month].selected=true;
  37. for(i = 0; i < 3; i++)
  38. {
  39. document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i);
  40. }
  41.  
  42.  
  43. if(curr_month==0 || curr_month==2 ||curr_month==4 || curr_month==6 || curr_month==7 || curr_month==9 || curr_month===11)
  44. {
  45. for(i=0;i<=30;i++)
  46.  
  47. document.getElementById('day').options[i] = new Option(i+1,i+1);
  48.  
  49. }
  50.  
  51. else if(curr_month==3 || curr_month==5 ||curr_month==8 || curr_month==10)
  52. {
  53. for(i=0;i<=29;i++)
  54.  
  55. document.getElementById('day').options[i] = new Option(i+1,i+1);
  56.  
  57.  
  58. }
  59.  
  60. if(curr_month==1)
  61. {
  62. var year=document.getElementById('year').value;
  63.  
  64.  
  65. if(checkleapyear(year))
  66. { for(i=0;i<=28;i++)
  67. document.getElementById('day').options[i] = new Option(i+1,i+1); }
  68. else
  69. { for(i=0;i<=27;i++)
  70. document.getElementById('day').options[i] = new Option(i+1,i+1);}
  71.  
  72. }
  73.  
  74. }
  75.  
  76.  
  77.  
  78. </script>
  79.  
  80. <body onLoad="populateYearSelect()">
  81.  
  82.  
  83. <select name="year" id="year" >
  84. </select>
  85.  
  86. <select name="month" id="month">
  87. <option value=01>JAN</option>
  88. <option value=02>FEB</option>
  89. <option value=03>MAR</option>
  90. <option value=04>APR</option>
  91. <option value=05>MAY</option>
  92. <option value=06>JUN</option>
  93. <option value=07>JUL</option>
  94. <option value=08>AUG</option>
  95. <option value=09>SEP</option>
  96. <option value=10>OCT</option>
  97. <option value=11>NOV</option>
  98. <option value=12>DEC</option>
  99. </select>
  100.  
  101. <select name="day" id="day">
  102. </select>
  103.  
  104. </body>
  105.  
  106.  
  107.  
  108. </html>
  109.  
Nov 6 '10 #1
Share this Question
Share on Google+
3 Replies


TonyBoy
P: 6
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:

Expand|Select|Wrap|Line Numbers
  1. <body onLoad="populateYearSelect()">
  2.  
  3.  
  4. <form action="" method="GET">
  5.  
  6. <select name="year" id="year" >
  7. </select>
  8.  
  9. <select name="month" id="month">
  10. <option value=01>JAN</option>
  11. <option value=02>FEB</option>
  12. <option value=03>MAR</option>
  13. <option value=04>APR</option>
  14. <option value=05>MAY</option>
  15. <option value=06>JUN</option>
  16. <option value=07>JUL</option>
  17. <option value=08>AUG</option>
  18. <option value=09>SEP</option>
  19. <option value=10>OCT</option>
  20. <option value=11>NOV</option>
  21. <option value=12>DEC</option>
  22. </select>
  23.  
  24. <select name="day" id="day">
  25. </select>
  26.  
  27. <input type="submit" />
  28. </form>
  29. </body>
  30.  
  31.  
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.
Nov 6 '10 #2

drhowarddrfine
Expert 5K+
P: 7,435
This must be done with javascript so this thread should be moved to that board.
Nov 6 '10 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
It has been moved.

Regards,

Jeff
Nov 7 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.