Re: Check null or 0
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Check null or 0

From: Matt Kruse <newsgroups@mattkruse.com>
Date: Mon Feb 27 2006 - 19:39:58 CET

staeri@gmail.com wrote:
> I'm using the following code to create a sum:
> forecast = forecast + eval(f[i].value);

Don't use eval.
http://www.JavascriptToolbox.com/bestpractices/

> This only works if "f[i].value" contains a number.
> Can someone please help me so that it also works if "f[i].value" is
> empty or contains text.

Well, what do you want it to do?
Should it treat non-number values as 0?
Ignore them?
Throw up an error?

-- 
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Received on Mon May 1 03:39:58 2006