javascript select tag configuration

by "Hansen" <vhanse31(at)maine.edu>

 Date:  Tue, 31 Jul 2001 06:29:15 -0400
 To:  hwg-basics(at)hwg.org
  todo: View Thread, Original
Hello

I'm working on a form that presently has selection boxes for 
inputting two sets of dates.  I have associated a function to the 
month selection tag through an OnChange event.  The function is 
supposed to calculate the number of days in that month and then 
rewrite the day selection box according to that calculation.  An 
example:  The page opens with the current date selected (July 30 
2001).  The user then clicks on the month box to change July to 
February.  The day box, which opens with day options from 1 to 
31, then is rewritten to display only days 1 to 28, since 2001 isn't a 
leap year.

The part of my function that calculates the number of days to 
display works fine.  However the part that rewrites the day options 
doesn't work right.

Here's part of the script:
//--numdays=# days in the month, defined in first part of function
//--daysinlist is initialized when the page loads to the current 
month's number of days, and then to the month selected.

//######remove the list options###################

if (daysinlist == null) {
        daysinlist = 31
}
removectr = 0;
while (removectr <= daysinlist) {
  document.DateSelectionForm.dateout.options[removectr]=null;
  removectr++;
}
daysinlist=numdays;


//######write new day list########################

datectr = 1;
while (datectr <= numdays) {
  newdate = new Option(datectr, datectr, false, false);
  document.DateSelectionForm.dateout.options[datectr] = newdate;
  datectr++
 }



When the remove part is run, it only removes the odd-numbered 
days.  Then the write part writes them back in with only a couple of 
duplicates.

Could someone please point out what I'm doing wrong.  I'm new to 
scripting with javascript, so getting this far has been a challenge.

Thanks for any assistance.

Victoria

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.