Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 22nd, 2004, 07:50 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checking for a Carriage return

I have this textarea where people can type whatever... I store the information in an Access DB, but when I retrieve the information it just displays it in a straight line.

How can I check when a user presses the 'enter' key, to replace it by a <br> or something like that...

Any ideas...

thankx

  #2 (permalink)  
Old December 23rd, 2004, 12:29 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

darkhalf,

1. This sample will work for windows encode and not in mac/unix encodes. If you want for that machines also do let me know.

2. This sample would convert the enter key at a stretch to break tags on click of a button. Instead if you want it to realtime, then use the Second Code snippet. (Note this sample will work for IE alone. For netscape you need use event.which in the function)

****FIRST Code snippet starts here ****
<html>
<head>
<script language="javascript">
function ConvertCarriageReturns(textarea, strReplace)
{
   textarea.value = escape(textarea.value)

   for(i=0;i<textarea.value.length;i++)
   {
      if(textarea.value.indexOf("%0D%0A") > -1 )
      {
         textarea.value = textarea.value.replace("%0D%0A",strReplace)
      }
   }
   textarea.value = unescape(textarea.value)
}
</script>
</head>
<body>
<form name="frmTest">
<textarea rows="7" cols="50" id="txtArea"></textarea>
<input type="button" onclick="ConvertCarriageReturns(this.frmTest.txtAr ea,'<br>')" value="Button">
</form>
</body>
</html>
****FIRST Code snippet ends here ****

RealTime Conversion:

****SECOND Code snippet starts here ****
<html>
<head>
<script language="javascript">
function RealTimeConvertion(e, textArea)
{
    var keyCode
     e = event
     keyCode = e.keyCode

   if(keyCode == 13)
   {
    textArea.value +="<br>"
    return true
   }
}
</script>
</head>
<body>
<form name="frmTest">
<textarea rows="7" cols="50" id="txtArea" onKeyPress="RealTimeConvertion(event,this)"></textarea></form>
</body>
</html>
****SECOND Code snippet ends here ****

Hope this helps!

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
  #3 (permalink)  
Old November 5th, 2007, 06:15 AM
Registered User
 
Join Date: Nov 2007
Location: Islamabad, Islamabad, Pakistan.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Sumaira.noreen Send a message via MSN to Sumaira.noreen Send a message via Yahoo to Sumaira.noreen
Default

Yea this works on IE but not on Mozilla...:(can you please help me...how can it work on Mozilla and mac? :(:(

Simply de Best...!!!


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert carriage return darkhalf Javascript 0 April 10th, 2007 02:42 PM
Carriage Return and Enter keys flashster BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 13th, 2006 06:38 AM
about carriage return... edu1980 XSLT 1 July 5th, 2006 04:11 AM
New Line/Carriage Return interrupt Javascript How-To 7 October 3rd, 2004 06:27 AM
HELP Inserting Carriage Return orangem Classic ASP Databases 8 July 5th, 2004 08:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.