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

Strange ASP/Javascript phenomenon

Status
Not open for further replies.

rtgordon

Programmer
Jan 17, 2001
104
US
This seems pretty strange to me, but the results of my ASP/Javascript code don't appear the way that I would anticipate. I don't uderstand the carriage returns in the output of my DescriptionLine1 variable in the client code. This gives me a "unterminated string constant" error, but when I look at the length, it is 60 DescriptionLine1, just as I would expect. take a look...

This is my ASP code
Code:
<%
Response.Write(Len(DescriptionLine1) & &quot;!&quot;) 'For troubleshooting
%>
var x = &quot;<%=Trim(DescriptionLine1)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine2)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine3)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine4)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine5)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine6)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine7)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine8)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine9)%>&quot; + &quot;\n&quot;;
x += &quot;<%=Trim(DescriptionLine10)%>&quot;;
document.modifyForm.desc.value = x;

This is what is generated on the client:
Code:
60!
<script language=&quot;JavaScript&quot;>

<!--
	var x = &quot;Testing out the new add and reported by









	&quot; + &quot;\n&quot;;
	x += &quot;		&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot; + &quot;\n&quot;;
	x += &quot;&quot;;
	document.modifyForm.desc.value = x;

 
I think that I have come accross a solution to the problem. Apparently, when moving from the textarea to the database, it was putting carriage returns on the end. I was able to extract them, but I think that I probably will remove them before the insert. Maybe something like this:

DescriptionLine1 = Mid(Description, 1, 60)
CrlfPosition = InStr(1, Description, chr(13), 1)
If CrlfPosition > 0 Then
DescriptionLine1 = Mid(DescriptionLine1, 1, CrlfPosition-1)
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top