Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic 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
 
Old March 16th, 2005, 01:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default How would you determine the "ENTER' key?

Hi All,

I have a text field in my SQL table.
How would you determine the "ENTER" keys in this text field?
When I display it in a table cell, it is basically a free text format.
But in a <TEXTAREA> tag, it lines up properly.

For example:
Text Field: This is the first line.
             This is the second line.

If I use <td> tag, it displays as
"This is the first line. This is the second line."

I I use <textarea> tag,
"This is the first line.
This is the second line."

So, if I can determine the "ENTER" keys, I can manually create new lines.

Thanks,

MCinar

Love all the creatures because of the creator.
__________________
MCinar

Love all the creatures because of the creator.
 
Old March 17th, 2005, 03:57 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need to replace the new line character
Code:
\n
with the HTMl break
Code:
<br>
.

--

Joe (Microsoft MVP - XML)
 
Old March 17th, 2005, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

or you could just use <pre> tags, they preserve line breaks
 
Old March 17th, 2005, 09:27 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

How are you setting the value? If you use innerText instead of innerHTML it should keep the breaks.

--

Joe (Microsoft MVP - XML)
 
Old March 17th, 2005, 11:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

DIM strValue

strValue = rs("text_field")

Thanks.

MCinar

Love all the creatures because of the creator.
 
Old March 22nd, 2005, 11:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Joe,

I used the following code, but it didn't help me to replace the "Break Line Code" with "<BR>".

Here is my code;


strBillingInstruction = rs("Billing_Instruction_TX")
strBillingInstruction = server.URLEncode(strBillingInstruction)
strBillingInstruction = REPLACE(strBillingInstruction, "%0D%0A","<BR />")
Response.Write strBillingInstruction

After using "REPLACE", I also like to reverse it back to normal text.
Thanks for your help,

MCinar

Love all the creatures because of the creator.
 
Old March 22nd, 2005, 12:01 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You don't need to URLEncode the data. You either need:
Code:
strBillingInstruction = REPLACE(strBillingInstruction, vbCrLf, "<BR />")
or
Code:
strBillingInstruction = REPLACE(strBillingInstruction, vbLf, "<BR />")
depending if the original text has carriage return and line feed or just line feed. I suspect it will be the latter.


--

Joe (Microsoft MVP - XML)
 
Old March 22nd, 2005, 12:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you, Joe.

MCinar

Love all the creatures because of the creator.
 
Old March 22nd, 2005, 10:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Joe,

I have one more question and I am not sure if it is possible.

I tried to implement the following in Classic ASP and it did not work properly. I hope there is a better solution in .NET.

" I have a "Combo Box" of companies.

One of the companies is "MICROSOFT".
When I press the letter "M", it jumps the first company that starts with the letter "M". What I am trying to achieve is to get to
"MICROSOFT" by pressing the letters "M, I, C and so on" on the Combo Box.

Right now, if you press "M" and then "I", it jumps to the first company that starts with the letter "I", which is the default setup."

Thanks,

MCinar

Love all the creatures because of the creator.
 
Old March 23rd, 2005, 04:43 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I have seen some boxes that do this, they use client side script to simulate the behaviour. Try searching for "dhtml combobox" or "javascript combobox". Or if you're feeling adventurous write your own. The basic technique is to trap the keypress and if it the first character or is pressed within a short time of the preceeding caharacter then search for the relevant entry.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter Key Event (Enter Key Only) Coby Excel VBA 0 February 6th, 2008 09:55 PM
use enter key to exit mastrgamr C++ Programming 1 January 18th, 2007 10:50 AM
Enter Key rwalker VB How-To 5 April 7th, 2004 11:04 AM
Using the TAB ORDER with ENTER KEY ? thomaz C# 0 September 10th, 2003 08:10 AM





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