By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Adding Break Tags to Input Form

P: n/a
**I'd like to know how to add break tags "<br>" inbetween entry's in
an input form, an example is if the word "yada yada" was entered you
would wind up with y<br>a<br>d<br>a<br> y<br>a<br>d<br>a

I would like to able to add the break tags with a button onClick. I have
no idea where to start, sorry. Any help is appreciated, Thanks Joe

Jan 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
do*****@webtv.net (Papajo) wrote in news:5644-43BF2BEE-207@storefull-
3332.bay.webtv.net:
**I'd like to know how to add break tags "<br>" inbetween entry's in
an input form, an example is if the word "yada yada" was entered you
would wind up with y<br>a<br>d<br>a<br> y<br>a<br>d<br>a
You are likely interested in learning about how to manipulate documents
with DOM methods.
I would like to able to add the break tags with a button onClick. I have
no idea where to start


Start with the following:

http://www.w3.org/DOM/
http://developer.mozilla.org/en/docs...y:DOM:Articles

The short lesson is that a document's structure and style can be
"objectified". Paragraph(s), sentences, words, characters---printable and
otherwise---can be treated as objects and properties gotten or set and
methods used to alter the objects. The document is structured as a TREE
with branch points (NODES). The document is rendered as a tree in this way
by the document reader/parser when initially loaded/read, but through these
DOM methods in script, these nodes can be INSERTED/APPENDED or REMOVED to
modify the document structure dynamically. A very simplified explanation.
Jan 7 '06 #2

P: n/a
Papajo wrote on 07 jan 2006 in comp.lang.javascript:
I'd like to know how to add break tags "<br>" inbetween entry's in
an input form, an example is if the word "yada yada" was entered you
would wind up with y<br>a<br>d<br>a<br> y<br>a<br>d<br>a


t1 = 'yada yada'

t2 = t1.replace(/( ?[^ ])/g,'$1<br>').replace(/<br>$/,'')

alert(t2)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 7 '06 #3

P: n/a
Thank you guy's, with the code snippet and lessons I was able to get
the script running. Joe

Jan 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.