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!

Help with Variables

Status
Not open for further replies.

Pryer

Programmer
Oct 24, 2005
12
US
I have an ASP script that is populating a javascript variable from a database. The current code i have works great in firefox, but in IE i'm having no luck. If you look at the example below you'll see that i have a comma at the end of my array. I don't know how to code arround this. Firefox does not care that my array has an extra comment, but silly IE hates it. Any suggestions?

CODE:

Response.write("<script language='javascript'>")
Response.Write("var TABLE_CONTENT = [ ")

Do until rs.eof
Response.write("[" & "'" & rs("procedure_num") & "'" & ", " & "'" & "<a href=""" & rs("location") & """> " & rs("procedure") & "</a>'" & ", " & "'" & rs("description") & "'" & ", " & "'" & rs("revision") & "' " & "],")
rs.movenext
loop
Response.Write(" ];</script>")
end if
RS.Close
 
instead of response.write, store the long string in a variable. then, take the entire string except the last character (since you know it will always be a comma) and response.write that to the page. use the left() function along with the len() function.



*cLFlaVA
----------------------------
[tt]( <P> <B>)[sup]13[/sup] * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Code:
Response.write("<script language='javascript'>")
<%
	dim tempStr
	do until rs.eof
		tempStr = tempStr & "[" & "'" & rs("procedure_num") & "'" & ", " & "'" & "<a href=""" & rs("location") & """> " & rs("procedure") & "</a>'" & ", " & "'" & rs("description") & "'" & ", " & "'" & rs("revision") & "' " & "],"
		rs.movenext
	loop
	tempStr = left(tempStr, len(tempStr) - 1)
		
%>

Response.Write("var TABLE_CONTENT = [ ")

response.write tempStr
Response.Write(" ];</script>")
end if
RS.Close

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
cLFlaVA & mwolf00

Thank you for your help, both of you gave me a way to fix my problem. Thank you guys...

Brenton Pryer
Pryer Machine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top