newline_to_br without breaking source code
Hello, i want to use a textarea form input in a java script and also in html tags. Wenn i use the newline_to_br attribut it works fine in html, but it breaks the source code. This is no matter in html, but in javascript. In javascript i want only the <br> but no linebreak. Does anybody has an solution for my problem ? Thanks Harry
webmaster@winkelmaenner.de wrote:
Hello,
i want to use a textarea form input in a java script and also in html tags. Wenn i use the newline_to_br attribut it works fine in html, but it breaks the source code. This is no matter in html, but in javascript.
In javascript i want only the <br> but no linebreak.
Does anybody has an solution for my problem ? Thanks Harry
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
why dont you just remove the linebreaks "\n" from the string with javascript ?
Hi, I think I understand your problem, but not why you run into it. Why do you not just omit the newline_to_br part where you use it in Javascript? Mabe you do have to explain your problem a bit better: Robert ----- Original Message ----- From: <webmaster@winkelmaenner.de> To: <zope@zope.org> Sent: Friday, February 15, 2002 9:01 AM Subject: [Zope] newline_to_br without breaking source code
Hello,
i want to use a textarea form input in a java script and also in html tags. Wenn i use the newline_to_br attribut it works fine in html, but it breaks the source code. This is no matter in html, but in javascript.
In javascript i want only the <br> but no linebreak.
Does anybody has an solution for my problem ? Thanks Harry
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
The rendered HTML sourcecode from zope always breaks the line, when somebody wrote text in a textarea field and used several lines manually. I can remove these "\n newlines" with javascript in the moment when somebody sends his form but then i have no possibility to have them back. For example in a tag like <dtml-var textAreaInputWithLinebreak newline_to_br> But i want to use it also in a <a href> tag like this: OnMouseOver="useUserTextAreaInput('<dtml-var textAreaInputWithLinebreak>')" and in 'normal' <dtml> tag like this: <dtml-var textAreaInputWithLinebreak newline_to_br> In the jacascript version the sourcecode will be broken without <br> In the dtml version the sourcecode will also be broken but also with <br> The javascript version returns in every case an error. thanks for help harry
Hi, I think I understand your problem, but not why you run into it.
Why do you not just omit the newline_to_br part where you use it in Javascript?
Mabe you do have to explain your problem a bit better:
Hello,
i want to use a textarea form input in a java script and also in html tags. Wenn i use the newline_to_br attribut it works fine in html, but it breaks the source code. This is no matter in html, but in javascript.
In javascript i want only the but no linebreak.
Does anybody has an solution for my problem ? Thanks Harry
Depending on what you want to accomplish by using the text value with javascript, this can be very tricky. For example, if you want to write a string that you later eval(), you have to handle line breaks. If you don't care how the string would be formatted on rendering, that's one thing, but preserving the line breaks may be something else. One approach to using multiline text is this: you can write multi-line string assignments by using a continuation character: var str='This is a \ multi-line string using \ continuation characters.' You can get this by inserting a backslash character just before each \n. If you want each line to remain on a separate line for visual formatting purposes, you can insert newlines : var str='This is a \n\ multi-line string using \n\ continuation characters.' Now all three lines will display as three lines in an alert or a text box, for example, whereas in the first example, you will see just a single line. This can be useful when you are creating javascript source code but probably will not help here. It seems to me that you ought be be able to manipulate the string using javascript in the browser, using regular expressions that are available in version 4 and later browsers. Thus OnMouseOver="line_fixing_javascript_function(useUserTextAreaInput('<dtml-var textAreaInputWithLinebreak>'))" The function line_fixing_javascript_function() would do something useful in formatting the string. Now if you know are going to do that in the browser, you can go farther. You can use a string replacement in dtml to get rid of any questionable characters, knowing that you can change them back at the browser. For example, change all "<br>" strings to "@@@@" or some such. Like I said, it can get tricky depending on what you want to accomplish. Tom P [<webmaster@winkelmaenner.de>] The rendered HTML sourcecode from zope always breaks the line, when somebody wrote text in a textarea field and used several lines manually. I can remove these "\n newlines" with javascript in the moment when somebody sends his form but then i have no possibility to have them back. For example in a tag like <dtml-var textAreaInputWithLinebreak newline_to_br> But i want to use it also in a <a href> tag like this: OnMouseOver="useUserTextAreaInput('<dtml-var textAreaInputWithLinebreak>')" and in 'normal' <dtml> tag like this: <dtml-var textAreaInputWithLinebreak newline_to_br> In the jacascript version the sourcecode will be broken without <br> In the dtml version the sourcecode will also be broken but also with <br> The javascript version returns in every case an error.
print TheTextWithLineBreaks.replace('\n','<br>') newline_to_br does: print TheTextWithLineBreaks.replace('\n','<br>\n') At 09:01 2002-02-15 +0100, webmaster@winkelmaenner.de wrote:
Hello,
i want to use a textarea form input in a java script and also in html tags. Wenn i use the newline_to_br attribut it works fine in html, but it breaks the source code. This is no matter in html, but in javascript.
In javascript i want only the <br> but no linebreak.
Does anybody has an solution for my problem ? Thanks Harry
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Peter Bengtsson -
Robert Rottermann -
Thomas B. Passin -
webmaster@winkelmaenner.de -
zope-mailinglist