Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28424
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Retrieve a select from a table cell |
| Date | Wed, 15 Jul 2015 00:23:38 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 68 |
| Message-ID | <5385669.KCYVbj6BcG@PointedEars.de> (permalink) |
| References | <mo2utl$9s5$1@dont-email.me> <mo3oq2$qo5$1@speranza.aioe.org> <mo3pud$u2u$1@speranza.aioe.org> <3951517.CJbgAzKFgc@PointedEars.de> <mo3rcn$2h2$1@speranza.aioe.org> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1436912806 14062 eJwFwYkBwEAEBMCWvItyxNF/CZlxBWPC4DA/v23pKKECsINdPrI3dx4VOpYqM19l00tWrh8izRES (14 Jul 2015 22:26:46 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Tue, 14 Jul 2015 22:26:46 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwFwQUBADAIALBKcDwO2j/CNyFFbWMVZTm5TJeMM+e6xjWqdRyH2BsbqacxPfNsc4C8LJiBTns7HB9/fBsWPA== |
| Cancel-Lock | sha1:T2ldblxJqE2MrPNtV6t9VLWCLwI= |
| X-NNTP-Posting-Host | eJwNxsEBwCAIA8CVQEiQdcRm/xHsvQ5B51QSTAha6bQbuLu6hfnLWvqCnbGNDivl0ehEZfUD/9wQMA== |
| Xref | csiph.com comp.lang.javascript:28424 |
Show key headers only | View raw
Joao Rodrigues wrote:
> Em 14/07/2015 17:07, Thomas 'PointedEars' Lahn escreveu:
>> Joao Rodrigues wrote:
>>> function cellClick(e) {
>>> var fc = e.target;
>>> if (/input|select/i.test(fc.tagName)) {
>>> window.alert(fc.type + " - " + fc.nodeName
>>> + " - " + fc.value + " - "
>>> + fc.nodeType);
>>> }
>>> }
>>
>> Not only as insufficient as your first approach (see my other follow-up),
>
> The OP's putclick() function didn't seem to take care of the select's
> options. She just added new selects with the DOMcreasel() function.
>
>> but even more inefficient and error-prone. If you are using a regular
>> expression, you need to anchor it to prevent false positives, at least
>> /^(input|select)$/i.
>
> More efficient, but unnecessary for the test case. Why do you always
> repeat it?
You are not making sense.
>> But you can do without such an expensive RegExp here.
>
> Expensive for modern JavaScript Engines? Nah.
A conforming implementation of ECMAScript Edition 5 and later is required to
create a new RegExp instance “each time the [/RegularExpressionLiteral/] is
evaluated”, and “[t]wo regular expression literals in a program evaluate to
regular expression objects that never compare as === to each other even if
the two literals’ contents are identical.” (§ 7.8.5). IOW, any optimization
is expressly forbidden there.
And if you want to be backwards-compatible, you cannot use non-capturing
parentheses for the anchored alternation, so each time the match is
performed memory must be allocated for the backreference.
Add to that the additional runtime for the matcher by comparison to simple
string comparison.
Besides, it is a misconception to assume that because there are “modern
JavaScript engines” the algorithms underlying one’s ECMAScript-based script
code would not need to be efficient. Because one cannot know in advance all
runtime environments one’s code will be exposed to.
>> Finally, the “input” appears to be coming from your imagination only;
>> read again.
>
> You should read again as you have forgotten the HTML table in the OP's
> code:
>
> | <TD><INPUT type='checkbox' name='chk'/></TD>
> | <TD><INPUT type='text' name='txt'/></TD>
The OP is evidentially not interested in the values of these controls: Both
the Subject header field value and their posting reads “Retrieve a *select*
from a table cell” (emphasis by me).
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Retrieve a select from a table cell "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-07-14 14:24 +0200
Re: Retrieve a select from a table cell "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-07-14 14:45 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 16:54 +0200
Re: Retrieve a select from a table cell "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-07-14 23:20 +0200
Re: Retrieve a select from a table cell "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-07-15 09:11 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 21:36 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 21:41 +0200
Re: Retrieve a select from a table cell "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-07-15 09:10 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-15 09:46 +0200
Re: Retrieve a select from a table cell "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-15 10:03 +0200
Re: Retrieve a select from a table cell "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-07-15 06:33 -0700
Re: Retrieve a select from a table cell "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-07-15 10:17 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-15 11:47 +0200
Re: Retrieve a select from a table cell "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-07-15 13:11 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-18 18:04 +0200
Re: Retrieve a select from a table cell Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-07-14 16:44 -0300
Re: Retrieve a select from a table cell Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-07-14 17:03 -0300
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 22:07 +0200
Re: Retrieve a select from a table cell Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-07-14 17:28 -0300
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-15 00:23 +0200
Re: Retrieve a select from a table cell Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-14 22:02 +0200
csiph-web