PDA

View Full Version : combining arrays ..



mtm
Nov 16th, 2003, 11:38 PM
I read SCromer on 11-5-03 on Arrays...
Read that to combine parts of different arrays, you can make each element a string and then combine them...

ex

eStr1 = Names[2]
eStr2 = Diameters[2]
eStr3= Mass[2]
//then combine -
eFacts = (eStr1 + eStr2 + eStr3)
document.write(eFacts)
----
or this way:

document.write((Names[0] + " ! <br> It's " + Diameters[0] + " and it " + Orbits[0] + ", plus it's " + Misc[0]+ "! <br>").toString());

With arrays & combined the strings, I have the info I need. The only prob I have now is how to use these strings in another window.
Can't see how, with the arrays in a parent page, I can get them to write to a popup window dynamically(?)

Thanks for any suggestions.

mtm:rolleyes:

swmr
Nov 17th, 2003, 07:16 AM
Maybe something like this?

var w = window.open("about:BLANK");
w.document.open();
w.document.write(eFacts);
w.document.close();

adios
Nov 17th, 2003, 07:30 AM
..........
eStr1 = Names[2];
eStr2 = Diameters[2];
eStr3= Mass[2];

eFacts = eStr1 + eStr2 + eStr3; //could also use eStr1.concat(eStr2, eStr3);
newwin = window.open('javascript&#58;opener.eFacts', 'newwin', '...features...' (http://www.webreference.com/js/column7/attributes.html));
if (newwin && !newwin.closed) newwin.focus();
}

Kor
Nov 17th, 2003, 09:37 AM
...if you want to use toString() method, you have to create the object first, i reckon... I mean, to create a new array

eFacts = new Array(.. ,.. , .. , ..)
document.write(eFatcs.toString())

But... hm. as far as I know there are some differences in the behavior of toString() method in javascript 1.3 according to javascript 1.2... So maybe is wisier to use classical combined strings