
Funny passing a text string from a database field to a Javascript global array
Hello all, I've had a rather perplexing problem with some javascript/ASP:
I have created a frameset where I have initialised a number of global
variables:
<html>
<head>
<title>ASP_frame.asp</title>
<script language="javascript">
var showprice = new Array();
var recordnumber = new Array();
var itemname = new Array();
var itemcode = new Array();
var totalrecordcount;
</script>
</head>
<frameset border="0" frameborder="0" rows="0%,100%">
<frame src="ASPblank.html">
<frame src="ASPfromweb3.asp">
<noframes>
<body>
</body>
</noframes>
</frameset>
</html>
Now, in the file ASPfromweb3.asp I pass values to the above variables
through a dociment.write command, part of which is:
+ '<form action="ASPviewbasket.asp" target=_self method=POST onsubmit='
+ 'top.showprice[<%=intNumRecs%>]'
+ '='
+ items[<%=intNumRecs%>].prprice
+ ','
+ 'top.recordnumber[<%=intNumRecs%>]'
+ '='
+ <%=intNumRecs%>
+ ','
+ 'top.itemname[<%=intNumRecs%>]'
+ '='
+ items[<%=intNumRecs%>].prname
+ '>'
etc....
Now, looking at the above code, the
top.showprice[<%=intNumRecs%>]=items[<%=intNumRecs%>].price has no problem
returning the number value from the database record. However when I try to
pass a text string through:
top.itemname[<%=intNumRecs%>]=items[<%=intNumRecs%>].prname I get a
"software" not defined error the moment you click on the submit button. This
happens whenever it encounters a text string. I was under the impression
that you did not have to declare variable types (as in C) - am I doing
something obviously wrong (I'm sure it's staring at me in the face).
Please help if you can. Kind regards George Pantela.