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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keeping form breaks

Status
Not open for further replies.

theocraticmind

Programmer
Apr 19, 2002
318
0
0
CA
ok, on one page, i have a textarea named post. on the next i have this:
Code:
  dim post

  post = request.form("post")
  
  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  
  Dim objFile
  Set objFile = objFSO.OpenTextFile(Server.MapPath("file.txt"), 8, True)
  
  objFile.WriteLine post

  objFile.Close
  Set objFile = Nothing
  Set objFSO = Nothing

ok, this takes out all breaks from the textarea. so:

jdh f
ds fjs
dfdfjfgg

would be:

jdh fds fjs dfdfjfgg

is there any way to stop this?

ps. is it posible to reverse append a text file? so that new content shows at the top?
 
yes
use this function:
Function BRFilter(strTextArea)
Dim intLoop
Dim strChar, strTemp

For intLoop = 1 to Len(strTextArea)
strChar = Mid(strTextArea, intLoop, 1)

If strChar = Chr(10) Then
strTemp = strTemp & &quot;<BR>&quot; & vbCrLf
Else
strTemp = strTemp & strChar
End If

Next

BRFilter = strTemp
End Function


use the function with that:
BRFilter(request.forn(&quot;post&quot;))


enjoy shai dayan
 
Here is a way for non-asp pages

<SCRIPT LANGUAGE=&quot;JScript&quot;>

function subInDivs()
{
var collTextAreas = document.all.tags(&quot;TEXTAREA&quot;);
var oNewDiv;
var sTemp;
var i;

for (i = 0; i < collTextAreas.length; i++)
{
oNewDiv = document.createElement(&quot;DIV&quot;);
oNewDiv.style.width = collTextAreas(i).clientWidth;
oNewDiv.style.height = collTextAreas(i).clientHeight;
oNewDiv.id = collTextAreas(i).uniqueID + &quot;_div&quot;;

// replace all line breaks with HTML line breaks
sTemp = collTextAreas(i).value.replace(/\n/gi,&quot;<BR>&quot;);

// match 2 spaces with to non-breaking spaces
sTemp = sTemp.replace(/\s\s/gi,&quot;&nbsp;&nbsp;&quot;);

oNewDiv.innerHTML = sTemp;
collTextAreas(i).parentNode.insertBefore(oNewDiv, collTextAreas(i));
collTextAreas(i).style.display = &quot;none&quot;;
oNewDiv = null;
}
}

function putBackTextAreas()
{
var collTextAreas = document.all.tags(&quot;TEXTAREA&quot;);
var oDivToRemove;
var i;

for (i = 0; i < collTextAreas.length; i++)
{
oDivToRemove = document.all(collTextAreas(i).uniqueID + &quot;_div&quot;);
if (oDivToRemove != null)
{
oDivToRemove.removeNode(true);
}
collTextAreas(i).style.display = &quot;&quot;;
}

}

</SCRIPT>

</HEAD>

<BODY>

<form>
<p><textarea rows=&quot;2&quot; name=&quot;S1&quot; cols=&quot;20&quot;></textarea><Button Class=&quot;ScreenOnly&quot; onclick=&quot;subInDivs();&quot; onclick=&quot;putbackTextAreas();&quot;>show breaks and no textarea box!</button></p>
</form>

</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top