364,083 Members | 5476 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

help with garden calendar

carletongardener
P: 5
I'm trying to make a calendar where the frost date is input and based on this date, a list of other dates are calculated that will be specific times from the input date. I have minimal programming skills and would appreciate any help.

I've gotten code that will input the frost date and output a single date (6 weeks prior to this date = tomato planting date). I wish the output button was a list of dates, or there were multiple buttons that pop up..... Maybe someone could help with adding one more date line and I can figure out how to repeat. Or direct me to the function I need to research more. Thanks!

test site: http://bioarray.us/generate%20planti...=5&d1=20&m1=10

code so far:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10.  
  11. <form>
  12.   <p>
  13.     <input type="text" name="date1" size="20">
  14.     <br>
  15. Date of last spring frost (mm/dd/yyyy)<br>
  16. Enter month and day of the latest spring frost in your garden in the past 5 years or so. If you don't know this, use the date from <a href="http://www.burpee.com/ancillary/zonefinder.do">Burpee</a> or <a href="http://cdo.ncdc.noaa.gov/cgi-bin/climatenormals/climatenormals.pl?directive=prod_select2&prodtype=CLIM2001&subrnum">NOAA</a>. For year, enter this year - 2009.
  17. <br>
  18. <br>
  19. <input type="button" value="Generate planting calendar!"
  20. onclick="finddates(this);" />
  21.   </p>
  22.   <p>&nbsp;</p>
  23.   <p>
  24.     <input type="text" name="date2" size="20" readonly>
  25.     Sow tomato seed indoors.<br>
  26.     <br>
  27.     <br>
  28.       </p>
  29. </form>
  30.  
  31. <script type="text/javascript">
  32.  
  33. document.forms(0).date1.value = dateToString(new Date())
  34.  
  35. function dateToString(d){
  36. return [d.getMonth()+1,d.getDate()].join('/')
  37.  
  38. }
  39.  
  40. function finddates(x){
  41. d = new Date(x.form.date1.value)
  42. d = new Date(d.getYear(),d.getMonth(),d.getDate()-40)
  43. x.form.date2.value = dateToString(d)
  44.  
  45.  
  46. }
  47. </script>
  48. <br>
  49. <br>
  50. <br>
  51. <br>
  52. <br>
  53.  
  54.  
  55.  
  56. </body>
  57. </html>
  58.  
  59.  
  60. </body>
  61. </html>
Feb 5 '09 #1
Share this Question
Share on Google+
10 Replies


David Laakso
Expert 100+
P: 392
@carletongardener
Move post to appropriate board on this forum. (X)HTML/CSS does not meet need required...
Feb 6 '09 #2

Dormilich
Expert Mod 5K+
P: 6,604
@carletongardener
you could use a couple of checkboxes to set the dates (tomato, cucumber, ...) to be computed. the checkboxes' value could be the number of days to subtract/add to the current date. this way, the function triggered by the button needs to fetch all the checked checkboxes using their passed value to compute the date.

for a better styling of the page have a look at CSS, especially the properties padding and margin should be good to start.

finally, I think you'd better use HTML than XHTML to start with
- true XHTML (with the recommended mime type "application/xhtml+xml") is not supported by Internet Explorer
- XHTML served as "text/html" is treated as HTML
- XHTML must be well-formed, otherwise browsers give you an error (the so-called Yellow Screen Of Death (YSOD))
(empty elements (like <img>, <br>, <hr>) are written <tagname/> (<img/>, <br/>, <hr/>), & must always be escaped)

regards
Feb 6 '09 #3

carletongardener
P: 5
Thanks for the suggestions!

I'm sorry I can't figure out how to move this thread and am not even sure where it should be moved to. (embarrassing...)

I converted to HTML, I think. I'm using DreamWeaver.

New test site: http://bioarray.us/planting%20calendar%202.html

Looks nicer now. I just need get the calculator functions to generate several different dates that are different lengths fo time form input date and enter these into the appropriate boxes.

New code:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <!-- DW6 -->
  4. <head>
  5. <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
  6. <title>Lodging - Calendar</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  8. <link rel="stylesheet" href="mm_lodging1.css" type="text/css">
  9. </head>
  10. <body bgcolor="#999966">
  11. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  12.     <tr>
  13.     <td width="15" nowrap>&nbsp;</td>
  14.     <td height="60" colspan="2" class="logo" nowrap><br>
  15.     Skippy's Vegetable Garden</td>
  16.     <td width="100%">&nbsp;</td>
  17.     </tr>
  18.  
  19.     <tr bgcolor="#ffffff">
  20.     <td colspan="4"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0"></td>
  21.     </tr>
  22.  
  23.     <tr bgcolor="#a4c2c2">
  24.     <td width="15" nowrap>&nbsp;</td>
  25.     <td height="36" id="navigation" class="navText"><a href="http://www.carletongarden.blogspot.com/">HOME</a><a href="javascript:;"></a></td>
  26.     <td>&nbsp;</td>
  27.     <td width="100%">&nbsp;</td>
  28.     </tr>
  29.  
  30.     <tr bgcolor="#ffffff">
  31.     <td colspan="4"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0"></td>
  32.     </tr>
  33.  
  34.     <tr bgcolor="#ffffff">
  35.     <td valign="top" width="15"><img src="mm_spacer.gif" alt="" width="15" height="1" border="0"></td>
  36.     <td valign="top" width="35"><img src="mm_spacer.gif" alt="" width="35" height="1" border="0"></td>
  37.     <td width="710" valign="top"><br>
  38.     <table border="0" cellspacing="0" cellpadding="2" width="610">
  39.         <tr>
  40.           <td class="pageName">Personalized Vegetable Garden Planting Calender</td>
  41.         </tr>
  42.     </table>
  43.     <p>Enter the date of your last srping frost (mm/dd/yyyy)
  44.     <form>
  45.   <p>
  46.     <input type="text" name="date1" size="20">
  47.     <br>
  48. Enter month and day of the latest spring frost in your garden in the past 5 years or so. If you don't know this, use the date from <a href="http://www.burpee.com/ancillary/zonefinder.do">Burpee</a> or <a href="http://cdo.ncdc.noaa.gov/cgi-bin/climatenormals/climatenormals.pl?directive=prod_select2&prodtype=CLIM2001&subrnum">NOAA</a>. For year, enter this year - 2009.
  49. <br>
  50. <br>
  51. <input type="button" value="Generate planting calendar!"
  52. onclick="finddates(this);" />
  53.   </p>
  54.   <p>&nbsp;</p>
  55.   <p>
  56.     <input type="text" name="date2" size="20" readonly>
  57.     Sow tomato seeds indoors.<br>
  58.     </p>
  59.   <p>
  60.     <input type="text" name="date3" size="20" readonly>
  61.     Sow cucumber seeds indoors.</p>
  62.   <p>
  63.     <input type="text" name="date4" size="20" readonly>
  64.     Sow sunflowers directly in the garden.</p>
  65.   <p><br>
  66.   </p>
  67.     </form>
  68.  
  69. <script type="text/javascript">
  70.  
  71. document.forms(0).date1.value = dateToString(new Date())
  72.  
  73. function dateToString(d){
  74. return [d.getMonth()+1,d.getDate()].join('/')
  75.  
  76. }
  77.  
  78. function finddates(x){
  79. d = new Date(x.form.date1.value)
  80. d = new Date(d.getYear(),d.getMonth(),d.getDate()-40)
  81. x.form.date2.value = dateToString(d)
  82.  
  83.  
  84. }
  85. </script>
  86. <br>
  87. <br>
  88. <br>
  89. <br>
  90. <br>
  91.  
  92.  
  93.  
  94. <br>
  95.      *  &nbsp;<br>
  96.       </p>
  97.      *</td>
  98.     <td>&nbsp;</td>
  99.     </tr>
  100.  
  101.     <tr>
  102.     <td width="15">&nbsp;</td>
  103.     <td width="35">&nbsp;</td>
  104.     <td width="710">&nbsp;</td>
  105.     <td width="100%">&nbsp;</td>
  106.     </tr>
  107. </table>
  108. </body>
  109. </html>
Feb 6 '09 #4

acoder
Expert Mod 10K+
P: 13,930
Line 71 document.forms(0) should be document.forms[0].

PS. please use [code] tags when posting code.

PPS. Moved to the JavaScript forum.
Feb 11 '09 #5

carletongardener
P: 5
Thanks SO much for the help! I'm all set. Here's the final link to my tool, if you want to generate a planting calender for your vegetable garden. http://bioarray.us/Skippy%27s%20plan...0calendar.html (Sorry I'm such a noob.)
Feb 12 '09 #6

David Laakso
Expert 100+
P: 392
Nice job. Validating the markup could be a nice touch. So might making it readable, for children of all ages, on landing. But these are trivial matters. Or, are they?
Feb 12 '09 #7

carletongardener
P: 5
Thanks. I validated. Don't know how to make it readable. K
Feb 12 '09 #8

David Laakso
Expert 100+
P: 392
Change the body declaration to read:
Expand|Select|Wrap|Line Numbers
  1. body { 
  2. font: 100%/1.4 Helvetica, Arial, sans-serif;
  3. margin:0;padding:0;
  4. background:#fff;
  5. }
  6.  
100% is default. 1.4 is line-height.

re: sans
Completely delete each and every font-size rule throughout the style sheet and the styles embedded in the head of the document. Each will inherit default (100%) sans from the body declaration.

re:serif
Change the font-size for TNR and Georgia to 100% with a raw number (as above) for line-height if even needed. Bump either or both up a little if you like.

re: sans and serif
Users will now get their preference, rather than yours. And should users who know how to use their machine decide to go up or down in size from their default by scaling the fonts, they can do so in compliant browsers, and more easily in the IEs as well...
Feb 12 '09 #9

carletongardener
P: 5
Thank you! I hope I did this right.
Feb 12 '09 #10

David Laakso
Expert 100+
P: 392
@carletongardener
So do i. Post to the forum and someone will check it...
Feb 13 '09 #11

Post your reply

Help answer this question



Didn't find the answer to your JavaScript / Ajax / DHTML question?

You can also browse similar questions: JavaScript / Ajax / DHTML calendar dates onclick