[thelist] testing for empty in javascript

Mike Carlson domitianx at domitianx.com
Tue Jul 16 13:03:01 CDT 2002


Why dont you just give each form field a different name and then add them all
up?

document.memberform.amountdue.value = document.memberform.zip1 +
document.memberform.zip2 + document.memberform.zip3.......

etc., etc....

It looks like the form is pretty static, its not like it dynamic. I am sure
you could come up with some sort of a loop to loop through all the form
fields with "Zip" in the name and add them up.

Mike

	-----Original Message-----
	From: Jeremy Weiss [mailto:jweiss at cei.net]
	Sent: Tue 7/16/2002 12:49 PM
	To: thelist at lists.evolt.org
	Cc:
	Subject: RE: [thelist] testing for empty in javascript



	The page is at https://whatsmyhomevalue.com/membership_form.htm

	We 'selling' zip codes to real estate agents.  The reason I want to
be able
	to remove one and have the total go down is b/c people tend to change
their
	mind.  An agent may want to purchase a several zip codes, but when
they see
	the total price they may decide they don't want so many zip codes and
thus
	they'll go back a remove a few of them.

	The site isn't finished yet so don't let errors surprise you.

	-Jeremy Weiss

	-----Original Message-----
	From: thelist-admin at lists.evolt.org
	[mailto:thelist-admin at lists.evolt.org]On Behalf Of Tom Dell'Aringa
	Sent: Tuesday, July 16, 2002 12:37 PM
	To: thelist at lists.evolt.org
	Subject: RE: [thelist] testing for empty in javascript


	Jeremy, could you maybe take a step back and tell us what the page
	needs to do? Adding up something, then turning around and removing it
	is work you shouldn't have to do I'm guessing. Maybe show us the
	whole page of code if its not too long, or give us a link, which is
	better.

	Tom

	--- Jeremy Weiss <jweiss at cei.net> wrote:
	> Okay, here's what I've got right now.
	>
	>
	> <script LANGUAGE="JavaScript">
	> var cost=0;
	> function ChangeTotal() {
	>    if(document.memberform.zip != "")
	>    {
	>       cost = cost + 1;
	>       amountdue = cost * 79.95
	>       document.memberform.amountdue.value = amountdue;
	>    }
	> }
	> </script>
	>
	> <form name="memberform">
	> <input type="text" name="zip" size="6"
	> onChange="ChangeTotal();">&nbsp;
	> <input type="text" name="zip" size="6"
	> onChange="ChangeTotal();">&nbsp;
	> <input type="text" name="zip" size="6"
	> onChange="ChangeTotal();">&nbsp;<br>
	> <input type="text" name="amountdue" size="20">
	> </form>
	>
	>
	> It works with the exception of two things.  1)When someone goes
	> back and
	> removes a zip code they typed in, it raises the total again.  I
	> need a way
	> to lower it in this instance.  2) The total needs to be formatted
	> as
	> currency, what's the easiest way to accomplish it?
	>
	> Sorry for all the remedial work I'm throwing out... think of it as
	> a
	> refresher course. ;)
	>
	> Thanks for all the help.
	>
	> -Jeremy Weiss
	>
	> --
	> For unsubscribe and other options, including
	> the Tip Harvester and archive of thelist go to:
	> http://lists.evolt.org Workers of the Web, evolt !


	=====
	var me = tom.pixelmech.webDeveloper();
	http://www.pixelmech.com/

	__________________________________________________
	Do You Yahoo!?
	Yahoo! Autos - Get free new car price quotes
	http://autos.yahoo.com
	--
	For unsubscribe and other options, including
	the Tip Harvester and archive of thelist go to:
	http://lists.evolt.org Workers of the Web, evolt !


	--
	For unsubscribe and other options, including
	the Tip Harvester and archive of thelist go to:
	http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list