Click to See Complete Forum and Search --> : js newbie


xtremcoder
01-23-2003, 01:18 AM
this is the first time ive ever messed w/ js - how do i make a new line of text? i tried /n but that didnt work :confused:

gil davis
01-23-2003, 06:08 AM
That would pretty much depend on where you shoved the "/n". That syntax only works in alerts, prompts and (I think) textareas. Everywhere else must be HTML (<br>).

xtremcoder
01-23-2003, 12:43 PM
<SCRIPT LANGUAGE = "JavaScript">
for(var lcv=0;lcv<=9;lcv++)
document.writeln(lcv);
</SCRIPT>

i tried <SCRIPT LANGUAGE = "JavaScript">
for(var lcv=0;lcv<=9;lcv++)
document.writeln(lcv+<br>);
</SCRIPT>
and it didnt work... any ideas :confused:

Webskater
01-23-2003, 12:51 PM
document.writeln(lcv+<br> );

should be:

document.writeln(lcv+'<br>' );

Here you are concatenating a string. You are joining a variable (which does not need quotes around it) with an html tag which does (as does text you want to write to the page).

xtremcoder
01-23-2003, 01:02 PM
ah hah! gotcha! thanks alot for the info!

khalidali63
01-23-2003, 01:32 PM
Originally posted by gil davis
That would pretty much depend on where you shoved the "/n".

Just a bit correction
its not "/n"

the correct syntax is
"\n"

and the above new line will work in javascript line display in the HTML you have to use <br>
<p> or or you may be able to use new line ascii value

Khalid