[thelist] testing for empty in javascript

Jeremy Weiss jweiss at cei.net
Tue Jul 16 12:33:00 CDT 2002


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




More information about the thelist mailing list