[thelist] testing for empty in javascript

Jeremy Weiss jweiss at cei.net
Tue Jul 16 17:23:06 CDT 2002


And now back to our movie of today, The Continuing Saga of the Wired but
Mentally Slow.

The script jeff sent me works great. Unfortunitly the value comes across to
the next page as a comma-delimited list.  How would I go about turning this
list into an array using VBScript?

-jeremy

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of .jeff
Sent: Tuesday, July 16, 2002 1:41 PM
To: thelist at lists.evolt.org
Subject: RE: [thelist] testing for empty in javascript


jeremy,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Jeremy Weiss
>
> The page is at
> https://whatsmyhomevalue.com/membership_form.htm
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

the verisign logo at the bottom of this page is causing a non-secure
elements warning in ie.  either make the request for the image from verisign
via ssl (https) or move a copy of the image to your own site and make the
request via ssl there like the rest of your images.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> 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.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

since all your zip code fields are named the same, they're accessible as an
array.  so, simply loop over that array of fields to get the total number of
fields with a value.  then, multiply the total number of fields by the price
per zip code and set your total amount due field to that value.

<script language="JavaScript" type="text/javascript">
<!--
  function DecimalFormat(number, places)
  {
    number = (Math.round(number * 100)) / 100;
    return (number == Math.floor(number)) ? number + '.00' : ((number * 10
== Math.floor(number * 10)) ? number + '0' : number);
  }

  var price_per_zip = 79.95;

  function ChangeTotal(oForm)
  {
   var zip_count = 0;
   for(i = 0; i < oForm.zip.length; i++)
   {
     if(oForm.zip[i].value)
       zip_count++;
   }
   oForm.amountdue.value = DecimalFormat(price_per_zip * zip_count, 2);
  }
// -->
</script>

additionally, make sure to pass a reference to the form object in your
ChangeTotal() function call in your onchange event handlers, like so:

onchange="ChangeTotal(this.form)"

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/


--
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