| Author |
Display each character on a new line
|
sadagi korbu
Greenhorn
Joined: Aug 16, 2006
Posts: 21
|
|
Hi all I am a beginer in html & javascript. I am trying to write a program which displays each character on a new line when a string is provided by the user. Can someone help me with the same. Regards
|
 |
Christophe Porteneuve
Author
Ranch Hand
Joined: Jan 28, 2008
Posts: 43
|
|
Hey Sadagi,
I am a beginer in html & javascript. I am trying to write a program which displays each character on a new line when a string is provided by the user.
Can you be more specific? What do you mean, "provided by the user?" Is it a form text input field? Is it a prompt dialog? Is it something else? Also, where do you want to display the result? In a message dialog? In the web page, as HTML? Finally, assuming you're trying to do that processing in JavaScript, the core of it can be done using regular expressions. Say you obtained the user's text in a variable called text. If you want to display it as independent lines in a dialog box (not HTML), you could go: If you want HTML (therefore requiring <br/> tags, unless your CSS respects line breaks), you would just change the replace expression like this: So let's say you have an element with id="foo" that you want to update with the result, you'd go: I hope this helps, [ February 12, 2008: Message edited by: Christophe Porteneuve ] [ February 12, 2008: Message edited by: Christophe Porteneuve ]
|
Christophe Porteneuve aka TDD
"They did not know it was impossible, so they did it." --Mark Twain
Pragmatic Guide to JavaScript: http://books.pragprog.com/titles/pg_js/
Prototype and script.aculo.us: http://books.pragprog.com/titles/cppsu/
|
 |
 |
|
|
subject: Display each character on a new line
|
|
|