Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript pattern matching problem 1

Status
Not open for further replies.

Ciarrai

Technical User
Jun 27, 2003
17
US
Hi,
I have created a html Page that allows a user to input data to a textarea on a form. On this I am using a Javascript function to ensure line returns are maintained by inserting <br> tags. This method, Validate(), is called when the form is submitted.
My problem however is this: Once the form is submitted it inserts <br> tags into the textarea. How can I display the data in the textarea without <br> tags while sending the contents of the textarea to the next page with <br> tags??
Any help would be greatly appreciated
Regards


<script type=&quot;text/javascript&quot;>
<!--
function validate()
{
var Txt = window.document.theForm.bodyText.value;
while (Txt.search(&quot;\n&quot;) > -1) {
Txt = Txt.replace (&quot;\n&quot;,&quot;<br>&quot;);
window.document.theForm.bodyText.value = Txt;
}
}

function valBodyText()
{
var Text = window.document.theForm.bodyText.value;
while (Text.search(&quot;<br>&quot;) > -1) {
Text = Text.replace (&quot;<br>&quot;,&quot;\n&quot;);
}
}
-->
</script>

<body onload = &quot;valBodyText()&quot;>

<form name = &quot;theForm&quot; method = &quot;post&quot; action = &quot;createBasic.asp&quot; enctype=&quot;multipart/form-data&quot; onSubmit=&quot;validate()&quot;>

<font size=&quot;2&quot; face=&quot;Arial&quot;>Insert the <b>text</b> in the box below that
you would like to appear on your home page<br>

<textarea name=&quot;bodyText&quot; rows=&quot;10&quot; cols=&quot;70&quot; wrap=&quot;virtual&quot;>
<%=rsGetValues(&quot;TextBody&quot;) %>
</textarea>

<center><input type=&quot;submit&quot; value=&quot;Test My WebPage&quot;>
</form>

</body>
</html>
 
do it server side with the replace function

replace (string, item to replace, items replacement)

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top