btcodeman
10-08-2003, 02:08 PM
I am having a bit of trouble getting my ASP section of code in below script to recognise and work with JS declared/assigned variable:-
The problem is in S3.2 - it says that the field is undefined. The purpose of this script is that it recieves the querystring of v_aqarr( which is an array) and v_totarr (array len) from another script). Once in my code I split into an array again to allow me to track question titles which are within the array. I then use these values to extract specific field names from source form. I know I could probably use elements direct via JS but I would like to go down this route if possible. Any ideas appreciated.
<%@ Language=JavaScript %>
<% Response.Buffer = "True" %>
<%
// S2 - Detect/Assign catch Vars
var v_aqarr = Request.QueryString("v_aqarr");
var v_totarr = Request.QueryString("v_totarr");
%>
<script language="Javascript">
// S3 - Assign Loop Controls
var v_fldarrcnt = <%=v_totarr%>;
var v_aqarr = '<%=v_aqarr%>';
var v_aqarr = v_aqarr.split(",");
document.write("Count = "+ v_fldarrcnt);
// S3.1 - Execute Loop
for (i=0; i < v_fldarrcnt ; i++) {
v_fldname = v_aqarr[i];
document.write("Debug - Field = " + v_fldname);
// S3.2 - Assign Field / Value from Questions
<%
var v_fldvalue = Request.Form(v_fld);
Response.Write("v_fldvallue = " + v_fldvalue);
%>
}
alert("Loop Complete");
</script>
%>
The problem is in S3.2 - it says that the field is undefined. The purpose of this script is that it recieves the querystring of v_aqarr( which is an array) and v_totarr (array len) from another script). Once in my code I split into an array again to allow me to track question titles which are within the array. I then use these values to extract specific field names from source form. I know I could probably use elements direct via JS but I would like to go down this route if possible. Any ideas appreciated.
<%@ Language=JavaScript %>
<% Response.Buffer = "True" %>
<%
// S2 - Detect/Assign catch Vars
var v_aqarr = Request.QueryString("v_aqarr");
var v_totarr = Request.QueryString("v_totarr");
%>
<script language="Javascript">
// S3 - Assign Loop Controls
var v_fldarrcnt = <%=v_totarr%>;
var v_aqarr = '<%=v_aqarr%>';
var v_aqarr = v_aqarr.split(",");
document.write("Count = "+ v_fldarrcnt);
// S3.1 - Execute Loop
for (i=0; i < v_fldarrcnt ; i++) {
v_fldname = v_aqarr[i];
document.write("Debug - Field = " + v_fldname);
// S3.2 - Assign Field / Value from Questions
<%
var v_fldvalue = Request.Form(v_fld);
Response.Write("v_fldvallue = " + v_fldvalue);
%>
}
alert("Loop Complete");
</script>
%>