Re: Confused on Syntax
- From: Dr J R Stockton <reply0711@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Mar 2007 11:30:15 +0000
In microsoft.public.scripting.jscript message <170CD7AB-E74E-4A40-BFC6-D
91ECE818DCE@xxxxxxxxxxxxx>, Mon, 12 Mar 2007 11:15:34, Mythran
<kip_potter@xxxxxxxxxxx> posted:
What I would use is the parseInt function (if you want integer values):
var uuuuuu = parseInt(document.FORM1.txtEnrl.value);
var vvvvvv = parseInt(document.FORM1.txtNoSnrs.value);
if (uuuuuu < vvvvvv * 3) {
...
If you say you would, I can believe that. But, if the input control
happens to contain a leading zero, the value then given may not be the
value expected. Function parseInt should always be given a second
parameter, unless the consequences of not doing so are both fully
understood and necessary.
Unary + will do what is wanted, and FWIW will do it quicker.
One could alternatively use if (vvvvv*3 - uuuuu > 0) { ...
It's a good idea to read news:comp.lang.javascript and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.
- References:
- Re: Confused on Syntax
- From: Mythran
- Re: Confused on Syntax
- Prev by Date: script to shutdown hard disk
- Next by Date: daylight savings in javascript
- Previous by thread: Re: Confused on Syntax
- Next by thread: Contenteditable Div on Enter
- Index(es):
Relevant Pages
|