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

Unwanted empty lines in TEXTAREA

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
I'm having this problem and I tried using TRIM to clean up all the empty space but not helping at all, hoping someone can point out why and how I can do this, here is the code:
Code:
<html>
<%
if request("form00")="1" then
	Set mainTxtFileObj 	= Server.CreateObject("Scripting.FileSystemObject")
	Set myOutStream		= mainTxtFileObj.OpenTextFile(Server.MapPath("db/mainTxt.txt"), 2, TRUE)
	myOutStream.Write(Request.Form("mainStr"))
	myOutStream.Close
	
	'Send them back to the default page
	Response.Redirect("default.asp") 
end if
%>
<body>
<form action="editMainTxt.asp" method="post">
	<textarea name="mainStr" cols="50" rows="10">
<%
		Set mainTxtFileObj	= Server.CreateObject("Scripting.FileSystemObject")
		Set mainTxtFile		= mainTxtFileObj.OpenTextFile(Server.MapPath("db/mainTxt.txt"))
		While NOT mainTxtFile.AtEndOfStream
			Response.write(mainTxtFile.ReadLine & vbCrLf)
		Wend
		mainTxtFile.Close
%>	
	</textarea>
	<BR />
	<input type="hidden" name="form00" value="1" />
	<input type="submit" value="Save" onclick="window.close()" />
	<input type="c"
</form>
</body>
</html>

Basically, my problem is that whenever this page opens, the TEXTAREA keeps include empty line on top and, at least, 2 or 3 lines below of the text; therefore, if I forget to delete those white lines and hit SAVE, the article where I want to display the text content will have those unwanted empty lines with along with the text. As I said, I used TRIM for all of the chances I got, but no help. Is there another way to do just that? Thanks!
 
Nevermind, I got it.
Instead of directly display text string utilizing Response.write, I assigned the string to a given variable, then display that variable with the TRIM, and it works!

Anyway, thank you for reading this thread of mine.
 
Or, something like this:
Code:
Dim sInput, arrInput, sCleanedInput
sInput = [i]value from TEXTAREA[/i]
arrInput = Split(sInput, vbCrLf)
For i = LBound(arrInput) To UBound(arrInput)
   If Trim(arrInput(i)) <> "" Then
      sCleanedInput = sCleanedInput & arrInput(i)
   End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top