Adding Break Tags to Input Form

P

Papajo

  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
 
L

Lee

Papajo said:
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 need to be more precise in describing what you want.
You talk about an "input form", but seem to mean a "text input element"
(or "text input control"). You say that you want the breaks to be
inserted "between entries", but your example shows it being inserted
between the non-whitespace characters of a single entry.

It might also help to know why you want this.
 
P

Patient Guy

(e-mail address removed) (Papajo) wrote in 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/Category: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.
 
E

Evertjan.

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)
 
P

Papajo

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top