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


Groups > comp.lang.javascript > #28411 > unrolled thread

Retrieve a select from a table cell

Started by"danca (Daniele Campagna)" <cyberdanny@tiscalinet.it>
First post2015-07-14 14:24 +0200
Last post2015-07-14 22:02 +0200
Articles 1 on this page of 21 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#28420

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-07-14 22:02 +0200
Message-ID<55A56ADB.60404@PointedEars.de>
In reply to#28417
Joao Rodrigues wrote:

> DOMcreasel() may be simplified to:
>
>   function DOMcreasel(tableID) {
>     var ns = document.createElement("SELECT");
>     ns.options[ns.options.length] = new Option('Memo', 'M');
> […]
>     var lastrow = document.querySelector("#" + tableID
>                 + ">tbody>tr:last-child");
>     var i = lastrow.cells.length;
>     lastrow.insertCell(i).appendChild(ns);
>   }

Yes, but then you would have to explain why you are combining the oldest
proprietary with the newest standards-compliant features in an error-prone
way.

> You are adding onclick event handlers to every child of the TDs, and
> fc.firstchild may be null depending on what you click (use Firefox /
> Firebug to see it for yourself).

Correct.  But if that had been the reason here, the result would not have
been an alert message, but a TypeError exception as “null as no properties”.

> […]
>>     var fc=this.firstChild;
>>     if (fc) {
>>      alert(fc.type+" - "+fc.nodeName+" - "+fc.value+" - "+fc.nodeType)
>>     }
>> […]
>>
>> When I click on the cell containing the first SELECT I have:
>> undefined - #text - undefined - 3
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> […]
>
> […]
>     var elems = tbl.querySelectorAll("input, select");
>     for (var i = 0, len = elems.length; i < len; i++) {
>       elems[i].addEventListener('click', cellClick, false);
>     }

The “click” event bubbles.  Even though you are wasting much less memory
than the OP, the loop and all those event listeners are unnecessary,
especially if one assumes W3C DOM compatibility as you do.

>   }
>
>   function cellClick(e) {
>     var fc = e.target;
>     window.alert(fc.type + " - " + fc.nodeName
>                  + " - " + fc.value + " - "
>                  + fc.nodeType);

Insufficient, even by your own account: “select” elements have child
elements.
 
.
.
.
.
.
.
-- 
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.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.javascript


csiph-web