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


Groups > comp.lang.javascript > #12175

Re: Cant use <input text as a numeric

From " Cal Who" <CalWhoNOSPAM@roadrunner.com>
Newsgroups comp.lang.javascript
Subject Re: Cant use <input text as a numeric
Date 2012-02-25 09:25 -0500
Organization A noiseless patient Spider
Message-ID <jiar18$rmp$1@dont-email.me> (permalink)
References (2 earlier) <4f481090$0$4322$a8266bb1@newsreader.readnews.com> <ji944q$8p3$1@dont-email.me> <2271012.FRqVoOGUtd@PointedEars.de> <ji9clr$oeh$1@dont-email.me> <XnsA0046458823CFeejj99@194.109.133.133>

Show all headers | View raw


"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message 
news:XnsA0046458823CFeejj99@194.109.133.133...
> Cal Who wrote on 25 feb 2012 in comp.lang.javascript:
>
>>> However, the proper way to refer to the value of the control is
>>>
>>>  document.forms["ScrabbleStopWatch"].elements["timeTotal"].value
>>
>> Does this work in IE and Firefox?
>
>> I've seen the getElementById used many times.
>> Is this the old way and what you show is now replacing it.
>> If so, why is the new way better?
>
> Please do not fixate on what is "better" in programming.
>
> Both ways are standard and so cross-browser compatible.
>
> ===
>
> IE allows document.aName where aName is the name of a form or another
> emenent. That is one of MS's serious mistakes, as it is not standard and
> even in IE leads to errors when is html-reserved and used, like the
> document.forms collection.
>
> ===
>
> document.forms["ScrabbleStopWatch"].elements["timeTotal"].value
>
> can be written as
>
> document.forms.ScrabbleStopWatch.elements.timeTotal.value
>
> which is ok, but
>
> document.forms[3].elements["timeTotal"].value
>
> is a bit dangerous, as the 4th form could later be shifted by you to
> another place, without you realizing the number should be changed.
>
> ===
>
> In simple testing I use document.forms[0], to point to the first [and
> only] form, all the time.
>
> ===
>
> Using this or this.form is nice:
>
> <form onsubmit='alert(this.name+" to be submitted NOW.")' name='myForm'>
> <input type='submit' onclick='alert(this.form.name+" submits shortly.")'>
> </form>
>
> especially if you use a common [to more forms or inputs] function:
>
> <input onclick='myFunc(this)'>
>
> ===
>
> document.getElementById() can always be used and is quite safe when you
> rmember an id must be unique in html.
>
> ===
>
> btw, please sign with a nickname or preferably your own name on this NG,
> talking to and quoting anonimous is cumbersome.
>
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Thanks
Cal 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next 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