Click to See Complete Forum and Search --> : Line Break Question


knightyme
12-06-2002, 06:15 PM
I'm writing a script that has, in one section, a text box. When the visitor, to my site, uses the script, they will type several lines within this textbox. As such, I have installed a 'Preview' button, that when clicked, will allow the visitor to read or preview what they have typed, in an 'alert' or 'confirmation' window which pops up.

Below is my problem.

Next to the text box, I have included instructions, which include "when typing multiple paragraphs and/or lines, us '\n' to instruct the script to form a 'line break'."

This is successful, when the visitor ultimately generates the desired script but...the annoying thing is that the line break code (\n) which I have instructed them to use, shows up in the preview window, along with whatever they have typed.

Is there any way to have my visitors continue using the line break code but make it invisible in the preview popup?

Thanks!

Zach Elfers
12-06-2002, 06:47 PM
Tell them to type <br> or get a JavaScript which converts the returns.

knightyme
12-06-2002, 06:53 PM
Actually, the javascript which converts the returns may do what I need. However, I'm not aware of where I might locate such a script. And, the way it's set up, <br> will not work. It must be '\n' and that's what I'm trying to make 'invisible.'

Thanks.

Zach Elfers
12-06-2002, 06:58 PM
The script is on this site. It is in the "forms" section and I think it's title is "Converting Cariage Returns" or something like that.:)

jeffmott
12-06-2002, 07:00 PM
Tell them to type <br>

This won't do anything in an alert window.

or get a JavaScript which converts the returns

Pretty sure that's what the OP was asking for to begin with.

Is there any way to have my visitors continue using the line break code but make it invisible in the preview popup?

var re = new RegExp(/\\n/);
alert(document.form_name.textbox_name.value.replace(re, "\n"));

knightyme
12-07-2002, 07:50 AM
I appreciate the replies from both of you.

I'm still looking for the script Zach mentioned but I'll find it.

And Jeff, thanks, I'll test that snippet of code and let you know if it works.

Happy Holidays all! :)

knightyme
12-07-2002, 04:06 PM
Jeff, I've placed that code just about every place I can think of to do so, and it's not working. I do suspect it's based on my own ignorance though, as I've only completed four projects in javascript.

jeffmott
12-07-2002, 06:42 PM
The parts that say form_name and textbox_name you do have to replace with the actual names of those elements.