[Javascript] Calculating large number of different values

Fred Newtz fred at newtz.us
Fri Aug 5 12:24:04 CDT 2005


Well everything was going great.  I integreated the code into three
different pages, one for Lunch and Supper, and one for the three snacks that
are served and of course one for Breakfast.  I added the code to take care
of the fact that there was more than one meal that could be planned for that
page.  However, now I am working on the infants menu planning page.  

I have posted a rendered (from PHP) page here:
http://www.newtz.us/test.html 
Here is the javascript that I have started and am too confused to get much
farther:
http://www.newtz.us/javascript.txt

So on this page there are three different age groups, 0-3 months, 4-7 months
and 8-11 months.  However, 0-3 month only get milk, 4-7 month get milk and
cereal and 8-11 month get milk, cereal and fruit.

I am assuming I am going to have to make three different for loops here.
One for the 0-3 months, etc..  However, I am confused as to how I should
name my textboxes now to work with my looping structure.  

I started trying to name my textboxes but I keep feeling that I need to make
my looping structure before I make the names for the text boxes.  What
should come first?  The field names/ids or the looping structure?  What is a
good way to plan for the names use and how you are looping through them?

Thanks again,

Fred

-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Fred Newtz
Sent: Thursday, August 04, 2005 6:41 PM
To: '[JavaScript List]'
Subject: RE: [Javascript] Calculating large number of different values

Thank you for the reply first of all.  I thought I would be all on my own
trying to figure this out.   

An oversimplification is probably what needed to happen in the first place.
Sorry I did not put a code link but I have confidential data in there right
now.  I will move it to a different site and put dummy data in there, if I
need more help.  :-)

The drop downs did serve the purpose to allow the user to change the date to
set future meal menus.  At some point it will also serve to allow them to
look at previous menus also.  However, that is for a later date and time.
There are "potentially" different amounts of children attending for each day
of the week.  So when the date is changed it needs to be able to recalculate
the whole form, not just one row.  Obviously I can't just call the
initialize form function when the user changes the date, so I think I will
have to write a new function to pass the day of the week in there so it will
calculate the values for the proper day?  Or maybe I could just change the
initialize form function to always receive a date as a parameter.  

I really did not expect to receive all this code.  I sure do appreciate it
in a very big way.  I think I will be able to modify what you have here to
suit my needs.  You did for me in ~70 lines of code which took me ~350 lines
of code.  :-)  If I run into another problem I will be sure to post the code
for you to see.

Thanks again,

Fred


-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Triche Osborne
Sent: Thursday, August 04, 2005 2:10 PM
To: [JavaScript List]
Subject: Re: [Javascript] Calculating large number of different values

Hi Fred,
	I may be greatly over-simplifying your situation, and if so, I 
apologize, but there were a couple of points on which I was a bit fuzzy 
and you didn't include a link to the problem documents.
	Anyway, I made up a form and script to mimic the behavior you seemed
to 
be describing. Here is a link to my form and a text version of the JS 
driving it:

http://www.triche-osborne.com/testing/fred.html
http://www.triche-osborne.com/testing/fred.txt

There is a departure from your description of note:
	(1) You indicated that the set of dropdowns in your version were
"for 
the current date." Since you did not indicate that they performed any 
function other than obtaining the *current* date, I obtained it from the 
JS Date object instead. If you are concerned that the user's machine 
date will be inaccurate or if they perform some other function such as 
allowing the user to choose a future date for calculating projections, 
this is not appropriate, and you will need to put the dropdown(s) back in.
	If this is not what you were describing, perhaps you could clarify
the 
differences and include a link to the documents so that I/we have a 
better picture.

Triche Osborne

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list