Forums

This topic is locked

Line-changing in Forms

Posted 04 Jun 2002 18:54:55
1
has voted
04 Jun 2002 18:54:55 Kristian Waagsboe posted:
How does one arrange automatical line changes in multi-lined textboxes (textareas) so that when the users press enter, the text will break in the details page.

In example: A newswriter shall write an article, He or she wants a line change without using "<p>" which is html code. How do I fix that? On the detail news site, there is just drag and drop recordsets arranged. Thanks in advance ...

Replies

Replied 05 Jun 2002 09:21:25
05 Jun 2002 09:21:25 Viktor Farcic replied:
Use Replace function. Something like:
<%=Replace(Recordset("FieldName", VbCrLf, "<br />" %>

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
How does one arrange automatical line changes in multi-lined textboxes (textareas) so that when the users press enter, the text will break in the details page.

In example: A newswriter shall write an article, He or she wants a line change without using "&lt;p&gt;" which is html code. How do I fix that? On the detail news site, there is just drag and drop recordsets arranged. Thanks in advance ...
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Viktor Farcic
www.farcic.com
TalkZone Manager
Replied 05 Jun 2002 10:02:57
05 Jun 2002 10:02:57 Julio Taylor replied:
If you're using PHP, you can use the 'nl2br' code to convert all spaces into HTML compliant code.... for example:

&lt;?php echo nl2br( $recordset-&gt;Fields("field_name") ?&gt;

This should do the trick, it's what i use all the time for things like news items, etc.

I think that vafrcic wrote is the same thing but for ASP... i have zero knowledge of ASP so i was simply offering the PHP alternative since you didn't specify which server model you are using.

i hope this helps.

--J

P.S. i killed kenny
Replied 05 Jun 2002 17:42:21
05 Jun 2002 17:42:21 Kristian Waagsboe replied:
Sorry for forgetting server extension. It's ASP JavaScript.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Use Replace function. Something like:
&lt;%=Replace(Recordset("FieldName", VbCrLf, "&lt;br /&gt;" %&gt;
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

On the detail page? And if I wan't '&lt;p&gt;' i use something like this (just to se if I have understood):
&lt;%=Replace(Recordset("FieldName", VbCrLf, "&lt;p&gt;" %&gt;

I'm not all that well into scripting you see...
Replied 06 Jun 2002 00:47:14
06 Jun 2002 00:47:14 chris espino replied:
Replace VbCrLf in TextArea

It's in the tutorial section
www.udzone.com/showDetail.asp?TypeId=2&NewsId=1721

works perfectly! you just need to add 1 line.

Replied 06 Jun 2002 16:42:57
06 Jun 2002 16:42:57 Kristian Waagsboe replied:
Hmmm, this was pretty understandable but yet I have difficulties understanding what VbCrLf means. So if the users press enter twice on the form input, it will come up as an 2xbr/p ? Thanks for help though. I will surely test this one <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Replied 06 Jun 2002 23:19:30
06 Jun 2002 23:19:30 Kristian Waagsboe replied:
Is that script VB only? I CAN'T GET IT WORKING. Damn

Here's my code, works ok but won't include those nifty linebrakes...

// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 &lt; MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",";
var delim = (MM_typesArray[0] != "none" ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none" ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none" ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined" {
formVal = emptyVal;
} else {
if (altVal != "" {
formVal = altVal;
} else if (delim == "'" { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''" + "'";
} else {
formVal = delim + formVal + delim;
<b>FormVal = Replace(FormVal,vbCrLf,"&lt;br&gt;"</b>
}
}

MM_tableValues += ((i != 0) ? "," : "" + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "" + formVal;
}


and that linebrake showing in the post is only there because its a br tag there I guess, so it's not that which is the fault. Actually it's only there in the preview <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>

Edited by - Kr]st[an on 06 Jun 2002 23:20:43

Reply to this topic