View Full Version : Carriage Return FOR Javascript Code

10-13-2005, 03:38 PM
I'm trying to load an ASP recordset into a javascript array via an ASP array. The way I've been attempting to do it is by having ASP "Response.Write()" the javascript code that builds the javascript array. It ALMOST works :rolleyes:

The problem I'm having is that the ASP writes the different javascript lines as one long line (ie. no carriage returns). Therefore, the javascript lines are not recognized. When I take the source code and manually separate the lines produced...then when I run the modified source, it works fine.

I'm just wondering if javascript has a command to either goto the next line, or to signal the end of the command/line. Below is my "source" code (ie. the code the ASP produces)...

<p>PROFILE_CD value is: 3</p>
<p>NUM_REC value is: 6</p>
<script type='text/javascript'>//Builds the Javascript Array...//***************************************************var js_num_rec = 6var aTRANSfunc = new Array()aTRANSfunc[0] = new Array(2)aTRANSfunc[0][0] = 'CPDB54'aTRANSfunc[0][1] = '00'aTRANSfunc[1] = new Array(2)aTRANSfunc[1][0] = 'CPDB54'aTRANSfunc[1][1] = '01'aTRANSfunc[2] = new Array(2)aTRANSfunc[2][0] = 'CPDB54'aTRANSfunc[2][1] = '04'aTRANSfunc[3] = new Array(2)aTRANSfunc[3][0] = 'CPDB54'aTRANSfunc[3][1] = '05'aTRANSfunc[4] = new Array(2)aTRANSfunc[4][0] = 'CPDB60'aTRANSfunc[4][1] = '00'aTRANSfunc[5] = new Array(2)aTRANSfunc[5][0] = 'CPDB60'aTRANSfunc[5][1] = '01'</script>

<script type="text/javascript">
document.write("<p>The js_num_rec value is: " + js_num_rec + "</p>")
//Displays the Javascript Array...
document.write("<table border='1'>")
for (i=0;i<aTRANSfunc.length;i++)
document.write("<tr><td width='100'>")
document.write("</td><td width='100'>")
document.write("</td><td width='100'>")


Any assistance is greatly appreciated. Thanks.


10-13-2005, 08:40 PM
This is not a javascript problem, but the problem with ASP code, in particular how JS portion has been generated.

you should see something like:

var js_num_rec = 6;
var aTRANS;
func = new Array();
aTRANSfunc[0] = new Array(2);

instead of:
var js_num_rec = 6var aTRANSfunc = new Array()aTRANSfunc[0] = new Array(2)

it is possible VB mixed semicolons