javascript html type question
Author
Discussion

Code Monkey

Original Poster:

3,318 posts

287 months

Thursday 16th February 2006
quotequote all
i am writing to a cell characters from two different arrays.

ideally i would like to be able to insert a break in between the text from the two arrays

array1 = ("1","2"
array2 = ("A","B";

writing to the cell would like it to appear or at least how i imagine it would work

cells[c].write(array1[1] + <br> + array2[1]

1
A

putting the + in just turns the <br> into a string anyone else done this or can point me in the direction of how to do what i am attempting?

cheers,

mr_tony

6,351 posts

299 months

Thursday 16th February 2006
quotequote all
If you're writing this in Javascript then the page isn't going to reload (it's client based) - so writing a <br> tag to the page won't create the line break you wish for as the html isn't re-parsed for the tag to be read and the space placed.

Thats if I udnerstand correctly what you're trying to do.

IF you want to do this in jscript you need an object within the page that you can write to directly. E.g. a form / div etc... In fact possibly one easy way to do this is to have two DIV's one above the other and write output for first array to diva, then output from array to to divb...

OR if you want to put in a carriage return / line feed then it's ascii 10 / 13 (e.g. Chr(13) / Chr(10) ) etc





>> Edited by mr_tony on Thursday 16th February 16:53

slapmatt

1,132 posts

252 months

Friday 17th February 2006
quotequote all
These little examples should help you out:

alert("Hello World!";
alert("Hello <br>World!";
alert("Hello World!";

Balls - my code is so good even this forum does it!

What I'm trying to say is put a backslash n between Hello and World will make it appear on a new line.



>> Edited by slapmatt on Friday 17th February 11:08

shocker-z

554 posts

248 months

Friday 17th February 2006
quotequote all
not used javascript in ages but isnt what your after like this?

cells[c].write(array1[1] ."<br>". array2[1]);

i know in PHP i would just use

echo($array1['1'] ."<br>". $array2['1']);

not sure if this is what you ment or not..

GreenV8S

31,024 posts

314 months

Friday 17th February 2006
quotequote all
Is this all client-side? If so I'd just set the cell's innerHTML to the combined string; the browser will take care of any resizing etc that this causes.

Don

28,378 posts

314 months

Friday 17th February 2006
quotequote all
GreenV8S said:
Is this all client-side? If so I'd just set the cell's innerHTML to the combined string; the browser will take care of any resizing etc that this causes.


Does that work in Netscape? We use that all the time in our IE only stuff...