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


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

Changing letters in boxes

Started byfulio pen <fuliopen@yahoo.com>
First post2011-10-30 05:26 -0700
Last post2011-11-03 23:20 +0200
Articles 2 on this page of 22 — 9 participants

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


Contents

  Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 05:26 -0700
    Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-30 15:08 +0200
      Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 07:14 -0700
      Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 10:22 -0700
        Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-30 20:14 +0200
          Re: Changing letters in boxes fulio pen <fuliopen@yahoo.com> - 2011-10-30 12:27 -0700
      Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-30 18:58 +0100
        Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-30 19:07 +0100
        Re: Changing letters in boxes Andrew Poulos <ap_prog@hotmail.com> - 2011-10-31 06:15 +1100
          Re: Changing letters in boxes Lasse Reichstein Nielsen <lrn.unread@gmail.com> - 2011-11-01 17:17 +0100
            Re: Changing letters in boxes Andrew Poulos <ap_prog@hotmail.com> - 2011-11-02 07:10 +1100
              Re: Changing letters in boxes Andreas Bergmaier <andber93@web.de> - 2011-11-01 23:37 +0100
                Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-02 00:20 +0100
          Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-01 18:01 +0100
        Re: Changing letters in boxes Matt McDonald <matt@fortybelow.ca> - 2011-10-30 17:42 -0600
          Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-31 02:19 +0100
            Re: Changing letters in boxes Matt McDonald <matt@fortybelow.ca> - 2011-10-31 21:29 -0600
              Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-01 11:52 +0100
        Re: Changing letters in boxes RobG <rgqld@iinet.net.au> - 2011-10-30 19:33 -0700
          Re: Changing letters in boxes "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-31 08:37 +0200
          Re: Changing letters in boxes Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-31 11:50 +0100
    Re: Changing letters in boxes faqir <faqir@faqir.com> - 2011-11-03 23:20 +0200

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


#7892

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2011-10-31 11:50 +0100
Message-ID<1460484.mR14RZRZF0@PointedEars.de>
In reply to#7890
RobG wrote:

> Thomas 'PointedEars' Lahn wrote:
>> A safer approach is to remove all cells of the row except one, then
>> replace the content of the first cell and add more cells:
>>
>> var tr = document.getElementById("box");
>> var firstChild = tr.firstChild;
>> while (tr.lastChild != firstChild)
>> {
>> tr.removeNode(tr.lastChild);
>> }
>>
>> tr.cells[0].innerHTML = a;
> 
> You seem to be assuming here that the firstChild of the tr will be a
> cell (TD or TH), when it may be a text node:

ACK

> […]
> To get the first cell, better to be explicit:
> 
>     var firstCell = tr.cells[0];

ACK

> An alternative is getElementsByTagName('td')[0], but the cells can be
> TH or TD, using the cells collection deals with both.

A viable alternative alternative are the `firstElementChild' and 
`lastElementCild' properties if they are available.

> [...]
>> When all you know is jQuery, every problem looks $olvable.
> 
> <grin> is that one of yours?

Yes :)  It occurred to me when reading from John-David Dalton (@jdalton, on 
Twitter) that the jQuery Standards Group (sic!) he recently joined is going 
to suggest adding Array methods to NodeLists because they see so much 
[].forEach.call(hostObject) etc. these days.  Of course, my answer was – the 
fact aside that this would make the DOM API language-dependent – that in a 
well-developed Web application you seldom ever need [].….call(hostObject) to 
begin with.

> 1. http://msdn.microsoft.com/en-us/library/ms533897%28v=VS.85%29.aspx

Thanks a lot, for some reason I had to rely on long-forgotten table-
scripting experience with MSHTML and third-party information regarding this.  
It is acceptable to see this quirk being officially documented at last.

In fact, when you read on to [1] they are saying in the "Creating and 
Manipulating Tables" section that the `innerHTML' and `innerText' properties 
are *read-only* for `table' and `tr' objects, which makes kind of 
Microsoftish sense considering the quirks and their proprietary table object 
model.  This would mean it is not only unwise to use `innerHTML' there, but 
that it was functionally impossible.


PointedEars
___________
[1] <http://msdn.microsoft.com/en-us/library/ms532998(VS.85).aspx>
-- 
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

[toc] | [prev] | [next] | [standalone]


#7965

Fromfaqir <faqir@faqir.com>
Date2011-11-03 23:20 +0200
Message-ID<gLmdnZgiZ80WmC7TnZ2dnUVZ_qednZ2d@giganews.com>
In reply to#7819
10/30/2011 2:26 PM, fulio pen yazmış:
> Dear group members:
>
> I wanted to accomplish something, and know javascript or jquery can do
> the work, but my knowledge on both languages is too limited.  If
> possible, please help. My idea is in the following web page.
>
> http://www.pinyinology.com/js_learning/letters.html
>
> Thanks for your help.
>
> fulio pen
if you want to letters disappear one by one recognizably first you 
should call function letters three times recursively as 
letters('','b','c'), letters('','','c'),letters('','','')

but to make it recognizable letters function should use setTimeout 
functions as
var counter = 0;
function letters(a,b,c) {
    document.getElementById('box').innerHTML = '<td>' + a + '</td><td>' 
+ b + '</td><td>' + c +  '</td>' ;
  	if(counter ==0){
	        counter++;
		//wait 500 miliseconds
		setTimeout(letters('','','c'),500);

     	}
	if(counter ==1){
	        counter++;
		//wait 500 miliseconds
		setTimeout(letters('','','c'),500);

     	}

   }

[toc] | [prev] | [standalone]


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

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


csiph-web