Using JS to utilize line breaks in a text area

They have: 4 posts

Joined: Apr 2000

I am trying to write a 'quiz' to help my German class study for tests, and I have JS to generate a random vocabulary question. If they enter the wrong answer, I want it to list both the German word (in one textarea) and the English equivilant (in another next to it). I have everything working except one thing...I can't insert a line break in the textarea after each word, I have to add a comma and a space so all the words they missed read out like a list...that's not bad, but it would be better if each word (or phrase) was on a seperate line in each of their respective textareas. Can somebody tell me how to store a string in a variable with line breaks? (for instance, I want to say that
var document.forma.textarea1.value=
item1
item2
item3

with line breaks like that.

I know this is an incredibly confusing message, so here's the address of the page I'm working on...
http://www.michael.garrison.net/german_quiz.html

If you have any ideas, please e-mail me at [email protected] or post a reply here. Thanks!

By the way...when you open the above link, the quiz automatically starts...just incorrectly answer 2 or 3 questions, then when it asks you if you want to continue, click cancel, then you can maximize and examine the page. Thanks again.

[This message has been edited by james3mg (edited 04 April 2000).]

They have: 231 posts

Joined: Feb 2000

To insert a line break into a string use \n.

var document.forma.textarea1.value=
item1\nitem2\nitem3

They have: 4 posts

Joined: Apr 2000

Thank you...that worked wonderfully!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.