murrayatuptowngallery@yahoo.com wrote:[color=blue]
> Thank you, Mick.
>
> One more question regarding the table format below. It is apparent that
> yours has a totally different 'style' with more 'rules' than the most
> primitive form I employed.
>
> Is there a description of what structure your code conforms to?
> Is it DOM? The ; at end of each line and the variation in = and += are
> the kind of subtleties that have to be right and one will never get
> right without grasping how it all goes together.[/color]
a+=b
a=a+b
The expressions are equivalent, and are core javascript (part of the
language itself). The DOM is part of the browser, the DOM exposes
objects to javascript. (document, window etc.)
What I offered is a quick (and dirty) way of using js to write HTML. If
you are interested in the BIG picture, you need to familiarise yourself
with programming concepts - functions, parameters, scope, iteration etc.
The case that you present -stuffing array values into table cells- is
trivial, thus I offered a one-off solution.
I would approach the coding quite differently. I would look for a
*generic* way to accomplish the task at hand:
function stuffArrayValuesIntoTable(array,tableID){
//do stuff here
}
I try to avoid "document.write()" if I can, in favour of DOM techniques.
function stuffArrayValuesIntoTable(array,tableID){
if(!tableID){
// create a table
}
else{
var theTable;
if(theTable=document.getElementById(tableID)){//Table exists
if(array.length>0){//"array" looks like an Array
//do stuff with the table and array
}
}
else{//Flaky ID, or non-DOM browser
return;//exit function
}
}
For further reading:
http://www.mozilla.org/docs/dom/refe...avascript.html
Mick
[color=blue]
>
> I bounce from one on-line tutorial to another and find that I'm
> learning one command at a time but not the BIG picture.
>
> It's analogous to being illiterate and wishing to read Shakespeare.
> Figuring out how to build a learning curve is the next challenge.
>
> I suppose if I needed it for work I could take training courses. For a
> not-for-profit path, could you recommend any reading? It would be nice
> if I could answer more of my own questions, so I would be the only one
> hearing them repeated.
>
> Thanks
>
> Murray
>
>[color=green]
>>theTable='<table border="2"><tr><td>';
>>theTable+=AAA[0];
>>theTable+='</td><td>';
>>theTable+=AAA[1];
>>theTable+='</td></tr><tr><td>';
>>theTable+=AAA[2];
>>theTable+='</td><td>';
>>theTable+=AAA[3];
>>theTable+=</td></tr></table>;
>>document.write(theTable);
>>//or
>>document.write(AAA.join("<BR>"))
>>
>></script>
>>
>>Mick[/color]
>
>[/color]