hi there..

can i retrieve the break tag from querystring? i have a textarea which i store in a querystring. the textarea will not show the break tag if i have break tag among the text i typed.

let me explain in greater details. i have a dropdownlist whereby onclick it will store the values from other html inputs' values (textarea, dropdownlist) into the querystring, and the html inputs' values should remain. the problem is that if i have a chunk of words in a textarea where there are paragraph breaks and when the dropdownlist onclick triggers, there are no paragraph breaks, the words are all joined together.

here are my codes:

<textarea name="txt" id="txt" rows="5" cols="100" class="text" mandatory='true' display='txt' pattern='ALPHA_NUMERIC_PLUS'><%=request.QueryString("txt")%></textarea>

function check(){
	document.form.action = "page.asp?txt="+document.form.txt.value;
	document.form.submit();
}

Dani AI

Generated

Short summary: ’s textarea line breaks disappear because the raw value is concatenated into a URL without encoding, so newline characters are lost or normalized when the browser builds the query string. and correctly suggested avoiding GET for large/multiline data and converting between HTML breaks and newlines for display, and pointed to server-side helpers for presentation.

Immediate fix if staying with a query string: encode the textarea value on the client before appending it to the URL so CR/LF and special characters survive transport. For example, apply a URL-encoding function to the textarea content and then set the action. After that, the server-side query reader will receive the original line breaks (and they will render inside a textarea). See encodeURIComponent for details.

Additional points and cautions:

  • Query strings are visible in the address bar and have practical length limits in clients and servers; they are not appropriate for large or sensitive text. Session storage, POST submissions, or storing state on the server are safer alternatives.
  • When showing stored text back in an HTML textarea, output must be HTML-encoded server-side so markup inside the text does not break the page or create an XSS vector. If the stored form is HTML (with <br> tags) but the target is a textarea, convert those tags back into newline characters for correct display; conversely, convert newlines to HTML breaks when rendering into normal HTML flow.
  • For debugging, inspect the actual URL (or server logs) after encoding to confirm the %0A/%0D sequences are present, or log the raw form value before and after encoding.

These steps preserve authoring line breaks when a textarea value is transported in a URL while highlighting safer alternatives for larger or sensitive content.

Recommended Answers

All 3 Replies

Why use the querystring? Can't you use POST rather than GET? Also, you aren't supposed to enter HTML tags into a textarea... it should automatically "break" text according to the browser window size.

Agreed with tgreer. Better to use post in your form and retrive the data from texarea using request.form("txt"). Here is what I would normally do:

mytxt = request.form("txt")
' use one of the following depend how you want to display your data
mytxt = replace(mytxt, "<br>", Chr(13)) ' convert html tag into new line
mytxt = replace(mytxt, Chr(13), "<br>") ' convert new line/break into html tag

You may use \n instead of Chr(13)

.

when u output the php row write this

<?php
$query = "your select";
$result = mysql_query($query);
while($row = mysql_fetch_asssoc)
{
   nl2br($row['yourrow']);
}
?>

this is a php function use this hope it helps u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.