Gossamer Forum
Home : Products : DBMan : Customization :

Displaying spaces in textarea

Quote Reply
Displaying spaces in textarea
Some time back I had posted about being able to show line breaks in textareas so that records entered would look the same when you viewed them, the solution ended up being this:

$rec{'fieldname'} =~ s/\n/<BR>/g;

placed at the top of the sub html_record.
However, I'd also like to have something show the spaces as well so that indents etc show up correctly. I tried this:

=~ s/\s/&nbsp;/g;

But that ended up stripping out extra spaces and you'd end up seeing one loooooooong string of text.

Any ideas what that should be? I tried doing a google and wasn't able to find what I needed.
Thanks!
Quote Reply
Re: [shann123] Displaying spaces in textarea In reply to
You will notice in db.cgi sub join_encode it actually strips the leading and trailing spaces:

$tmp =~ s/^\s+//g; # Trim leading blanks...
$tmp =~ s/\s+$//g; # Trim trailing blanks...

I do believe the by removing these functions you will be causing potential problems with your database.

If you want to have the description formatted with spaces, etc. then have people use html codes that will display the text as they want .. but not corrupt your database in the process.

They could use for instance the blockquote tag or the various list display tags.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Displaying spaces in textarea In reply to
Hi Lois,
I'm actually using DBMan SQL version 1, which is based off of regular DBman. The only difference is that it reads/writes to an sql database rather than a flat file. Since it's basiclly the same, I posted here since most of the postings for the SQL forum is for version 2. Anyway, the SQL database doesn't seem to have any problems with spaces, so I don't think there's anything to worry about there.
As far as the tmp =~ s/^\s+//g; goes, I don't see that line anywhere and when I look at the entries in the database, they do have the spacing.. it's just not displaying when you view the records.
Thanks for the reply Lois! You're always so helpful and it's most appreciated by all! Smile

Last edited by:

shann123: Mar 9, 2005, 2:34 PM
Quote Reply
Re: [shann123] Displaying spaces in textarea In reply to
Check out the "external text" mod - that may help you find what you need.

Could you do
<pre>$rec['fieldName'}</pre>

But does the db strip out all of the formatting when the record is added? Not sure... That's why I think the external text mod will be a better choice. Each record will have it's own text file associated with it.

Check it out and see if it works for you.
Quote Reply
Re: [shann123] Displaying spaces in textarea In reply to
Quote:
I look at the entries in the database, they do have the spacing.. it's just not displaying when you view the records.

In html, when there are two or more spaces together, they only print out as one space. What you need to figure out how to do is to convert every two spaces which are next to each other into {space}&nbsp;. I'm no good at all with regular expressions, so I'm not sure what the syntax for it would be, but that's what you need to do in order to get multiple spaces to show up in the display.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Mar 15, 2005, 12:35 AM