Old 03-08-2011, 06:03   #1 (permalink)
krista.susanne
Registered User
 
Join Date: Aug 2011
Posts: 12
line breaks in textarea

Hi.

I'm pretty well a newbie at all this so I'm probably asking a stupid question, oh well I shall ask anyway.

I have an assignment for which I have to input text into a text input, outputting in into a text area. I have this working, however I need line breaks between the values which I can't seem to work out.

Here is the code I have so far
Code:
<html> <head> <script type="text/javascript"> function add() { document.getElementById("answer").value+=parseFloat(document.getElementById("num1").value); } </script> <body> <input type="text" id="num1"></input> <input type="button" value="Add to list" onclick="add();"></input> <br /> <textarea name="text" rows="5"cols="5" readonly="readonly" id="answer"></textarea> </body> </html>

I need to be able to input individual values in the text box, and have them add to the list of values it is creating in the textarea.

Any help appreciated
  Reply With Quote
Old 03-08-2011, 06:39   #2 (permalink)
calder12
Senior Member
 
calder12's Avatar
 
Join Date: Apr 2011
Location: Ontario, Canada
Posts: 10,634
Code:
document.getElementById("answer").value+=parseFloat(document.getElementById("num1").value) + '<br />';

Should do it.
  Reply With Quote
Old 03-08-2011, 08:01   #3 (permalink)
krista.susanne
Registered User
 
Join Date: Aug 2011
Posts: 12
Thanks for that, I tried it, but it's simply inputting '<br />' into the textarea
  Reply With Quote
Old 03-08-2011, 08:02   #4 (permalink)
krista.susanne
Registered User
 
Join Date: Aug 2011
Posts: 12
never mind, I replaced "<br />" with "\n" and problem is solved! thanks for your help though!
  Reply With Quote
Old 03-08-2011, 13:47   #5 (permalink)
calder12
Senior Member
 
calder12's Avatar
 
Join Date: Apr 2011
Location: Ontario, Canada
Posts: 10,634
Oh, sorry was very late here, didn't read all the code. I thought you were just inputting the answers into a div not an actual text area.

Glad you got it sorted though.
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8