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


Groups > comp.lang.javascript > #12258

Re: Cant use <input text as a numeric

Newsgroups comp.lang.javascript
Subject Re: Cant use <input text as a numeric
From "Evertjan." <exjxw.hannivoort@interxnl.net>
References (7 earlier) <lgunk7p817n3bqiap7ud9g9t9sdvkcsvqt@4ax.com> <XnsA006EAFCAA9B9eejj99@194.109.133.133> <at8ok7doujeoccivicjr76gsh4l7pgp01u@4ax.com> <6bfXhBDfCLTPFwoE@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <q2fqk7db3viqv85nd0hduoodh5hr8qugbb@4ax.com>
Message-ID <XnsA0085A9AC5DCeejj99@194.109.133.133> (permalink)
Date 2012-02-28 23:33 +0000

Show all headers | View raw


Gene Wirchenko wrote on 28 feb 2012 in comp.lang.javascript:

> On Tue, 28 Feb 2012 10:46:55 +0000, John G Harris
> <john@nospam.demon.co.uk> wrote:
> 
> [snip]
> 
>>"7.5.2 Element identifiers: the id and class attributes
>>
>>Attribute definitions
>>
>>id = name [CS]
>>    This attribute assigns a name to an element. This name must be
>>unique in a document."
> 
>      OK.
> 
>      So what about the example I posted?  How would you get the
> equivalent in valid form?


Cann't say as I don't want to use invalid code 
as a base for discussion of correct code.

If you want to address multiple html-elements as a collection, 
just name them the same, not id them.

=====================
<div name='a'>xxxxDIV</div>
<span name='a'>xxxxSPAN</span>
<b name='a'>xxxxB</b>

<script type='text/javascript'>

var collection = document.getElementsByName('a');

for (i=0;i<collection.length;i++) {
  var c = collection[i];
  alert(c.tagName + ': ' + c.firstChild.nodeValue);
};

</script>
=====================

Or you could fake an id-collection:

=====================
<div id='a0'>xxxxDIV</div>
<span id='a1'>xxxxSPAN</span>
<b id='a2'>xxxxB</b>

<script type='text/javascript'>

for (i=0;i<3;i++) {
  var c = document.getElementById('a' + i);
  alert(c.tagName + ': ' + c.firstChild.nodeValue);
};

</script>
=====================


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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