Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12188

Re: Cant use <input text as a numeric

From Dr J R Stockton <reply1208@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: Cant use <input text as a numeric
Date 2012-02-25 21:00 +0000
Organization Home
Message-ID <TyFLlfRmvUSPFw3Q@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <ji8ok2$30o$1@dont-email.me> <ji90vi$m4s$1@dont-email.me> <4f481090$0$4322$a8266bb1@newsreader.readnews.com>

Show all headers | View raw


In comp.lang.javascript message <4f481090$0$4322$a8266bb1@newsreader.rea
dnews.com>, Fri, 24 Feb 2012 22:34:56, Denis McMahon
<denismfmcmahon@gmail.com> posted:


>But the more common way these days

With the US-led dumbing-down of society, "common way these days" is an
unreliable commendation.

>is to not use a form if you're not
>actually submitting the form data in a request, rather assign each field
>an id value and:

Using IDs more liberally than is necessary goes against the whole idea
of structured programming.  One should use the DOM tree.  But, with a
form, it is easy to address, by name, controls on the form.


>document.getElementById("element_id").value = "a string value";
>
>var strval = document.getElementById("element_id").value;
>
>var intval = parseInt(document.getElementById("element_id").value);

Method parseInt should always have a second argument, usually 10, unless
circumstances prove it unnecessary.  Using unary + is safer unless some
special property of parseInt is needed.

>var floatval = parseFloat(document.getElementById("element_id").value);

Unary + generally serves.

-- 
 (c) John Stockton, nr London UK.  ?@merlyn.demon.co.uk  DOS 3.3 6.20 ; WinXP.
   Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
   PAS EXE TXT ZIP via  <http://www.merlyn.demon.co.uk/programs/00index.htm>
   My DOS  <http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 14:32 -0500
  Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 16:54 -0500
    Re: Cant use <input text as a numeric Denis McMahon <denismfmcmahon@gmail.com> - 2012-02-24 22:34 +0000
      Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 17:48 -0500
        Re: Cant use <input text as a numeric Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-25 00:33 +0100
          Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 20:14 -0500
            Re: Cant use <input text as a numeric "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-25 08:51 +0000
              Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-25 09:25 -0500
              Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-27 13:49 -0800
                Re: Cant use <input text as a numeric "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-27 22:06 +0000
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-27 17:00 -0800
                Re: Cant use <input text as a numeric John G Harris <john@nospam.demon.co.uk> - 2012-02-28 10:46 +0000
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-28 12:45 -0800
                Re: Cant use <input text as a numeric "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-28 23:33 +0000
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-28 17:04 -0800
                Re: Cant use <input text as a numeric "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-29 09:11 +0000
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-29 14:07 -0800
                Re: Cant use <input text as a numeric "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-29 22:23 +0000
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-29 16:04 -0800
                Re: Cant use <input text as a numeric Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-02-28 01:58 +0100
                Re: Cant use <input text as a numeric Gene Wirchenko <genew@ocis.net> - 2012-02-27 21:31 -0800
                Re: Cant use <input text as a numeric Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-02-28 21:41 +0000
                Re: Cant use <input text as a numeric Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-03-01 20:52 +0000
            Re: Cant use <input text as a numeric Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-25 13:12 +0100
        Re: Cant use <input text as a numeric Denis McMahon <denismfmcmahon@gmail.com> - 2012-02-25 04:36 +0000
          Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-25 09:13 -0500
        Re: Cant use <input text as a numeric Denis McMahon <denismfmcmahon@gmail.com> - 2012-02-25 04:41 +0000
          Re: Cant use <input text as a numeric Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-25 13:13 +0100
            Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-25 09:17 -0500
              [OT] Quoting style (was: Cant use <input text as a numeric) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-27 17:52 +0100
          Re: Cant use <input text as a numeric " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-25 09:15 -0500
      Re: Cant use <input text as a numeric Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-25 21:00 +0000

csiph-web