Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12518
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Referring to Controls by id |
| Date | 2012-03-08 19:26 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <nltil7hkrg8hbbcc2pilp62jg80a8fkf3f@4ax.com> (permalink) |
| References | <191dl7ltuts723trrgoj29mln2b3uvqflk@4ax.com> <4f56ba86$0$2810$a8266bb1@newsreader.readnews.com> <XnsA00F7461D2062eejj99@194.109.133.133> <2g4fl7pjlg8ti787d1nael0mfa7ka92oei@4ax.com> <XnsA0106D358FECFeejj99@194.109.133.133> |
On 08 Mar 2012 09:44:09 GMT, "Evertjan."
<exjxw.hannivoort@interxnl.net> wrote:
>Gene Wirchenko wrote on 07 mrt 2012 in comp.lang.javascript:
>
>> On 07 Mar 2012 10:26:27 GMT, "Evertjan."
>> <exjxw.hannivoort@interxnl.net> wrote:
>>
>>>Denis McMahon wrote on 07 mrt 2012 in comp.lang.javascript:
>>>
>>>> On Tue, 06 Mar 2012 14:03:52 -0800, Gene Wirchenko wrote:
>>>>
>>>>> I suppose I will just change everything to use
>>>>> document.getElementById(), but the above is shorter.
>>>
>>>Indeed, using IE-only code is a bad idea.
>>>
>>>But "everything"?
>>
>> I think so. A lot of my code operates by fieldname. I have an
>> object associated with each control that has properties used with it:
>> name, datatype, size, formatting options, validation code, etc.
>
>What is a fieldname [in HTML]?
It is not a term in HTML (that I know of). It is the name of an
input field, such a "CliCode". The corresponding input control has
that name as its id.
>Do you mean the <td> cells of a <table><tr> row?
No, but I do put the input controls in <td>s.
>There are nice DOM-methods for that: [not tested]
>
>var myTables = document.getElementsByName('myTables');
I was doing this (and appending "[0]") to get the control object.
Since Gebi()ed.
>myTables[2].tBodies[7].rows[31].cells[12].style.color = '#a00';
I do not think of the fields by number but by name. If I changed
their order, I would not have to change code references.
>or:
>
>function getCellContent(table,row,cell) {
> var myTables = document.getElementsByName(table);
> return myTables[0].rows[row].cells[cell].innerHTML;
>};
Interesting, but not for me ATM. My data is in input controls.
[snip]
>>>> You could wrap document.getElementById thus:
>>>> function el( id ) { return document.getElementById( id ); }
>>>
>>>This function is most commonly named gebi()
>>
>> Already thinking of it.
>
>;-)
And I have done it except I called mine Gebi().
Sincerely,
Gene Wirchenko
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Referring to Controls by id Gene Wirchenko <genew@ocis.net> - 2012-03-06 14:03 -0800
Re: Referring to Controls by id Jeff North <jnorthau@yahoo.com.au> - 2012-03-07 09:23 +1100
Re: Referring to Controls by id Gene Wirchenko <genew@ocis.net> - 2012-03-06 15:02 -0800
Re: Referring to Controls by id Jeff North <jnorthau@yahoo.com.au> - 2012-03-07 19:08 +1100
Re: Referring to Controls by id "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-03-07 10:44 +0200
Re: Referring to Controls by id Jeff North <jnorthau@yahoo.com.au> - 2012-03-07 23:32 +1100
Re: Referring to Controls by id Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-07 21:26 +0000
Re: Referring to Controls by id Denis McMahon <denismfmcmahon@gmail.com> - 2012-03-07 01:31 +0000
Re: Referring to Controls by id Gene Wirchenko <genew@ocis.net> - 2012-03-06 22:33 -0800
Re: Referring to Controls by id Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-08 19:06 +0000
Re: Referring to Controls by id "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-07 10:26 +0000
Re: Referring to Controls by id Gene Wirchenko <genew@ocis.net> - 2012-03-07 08:55 -0800
Re: Referring to Controls by id "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-08 09:44 +0000
Re: Referring to Controls by id Gene Wirchenko <genew@ocis.net> - 2012-03-08 19:26 -0800
csiph-web