Preserving Line Breaks in ASP Querystring
This is a testing one.
I want to pass the value of a textarea message to an ASP page in a pop-up window using the window.open() javascript method. The url for window open method includes the value of the textarea as a parameter in the ASP querystring. ie:
window.open('preview.asp?msg=' + document.form.textarea1.value)
I bring the value into the pop-up page using: message=Request.Querystring("msg")
Then display it using:
<?php
=message
?>
Problem? The Linebreaks in the textarea message are not preserved!
When you pass the textarea value by submitting the form using the POST method, the Linebreaks ARE preserved. You can display them using ASP no worries by replacing them with tags like this:
<?php
=Replace(message,vbCrLf,"<br>")
?>
I don't want to have to submit the editing page, I want it to remain onscreen while the preview window pops up, hence passing the message through the javascript/asp querystring.
If this problem can be solved, I want to know how!
Cheers,
Hopster.
The more you learn the more you know how much there is you don't know.
Mark Hensler posted this at 06:09 — 17th September 2001.
He has: 4,048 posts
Joined: Aug 2000
try this:
window.open('preview.asp?msg=' + escape(document.form.textarea1.value))
Javascript functions:
escape() = encodes string for querystring
unescape() = decodes strings from querystring
I haven't used them much at all, so I can't really tell you much more. I'm not sure that it will encode line breaks, but worth a try.
Good Luck,
Mark Hensler
If there is no answer on Google, then there is no question.
Guy Hopkins posted this at 08:06 — 17th September 2001.
They have: 10 posts
Joined: Aug 2001
Brilliant! Line breaks preserved.
I knew it would be either something very simple or something impossible. On this occasion in was the former.
Thanks a million...
Hopster.
The more you learn the more you know how much there is you don't know.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.