Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-08-2003, 02:08 PM   PM User | #1
btcodeman
New to the CF scene

 
Join Date: Sep 2003
Location: Liverpool
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
btcodeman is an unknown quantity at this point
Javascript and Active Server Page variable references

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>
%>
btcodeman is offline   Reply With Quote
Old 10-08-2003, 08:34 PM   PM User | #2
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
in this line:

var v_fldvalue = Request.Form(v_fld);

you try to enter the value from a posted (method = post) formfield into variable v_fldvalue. The fieldname you are querying is stored in the variable v_fld. As far as i can see in your code, this variable is not filled with a value, so it is undefined. i think it is trying to look at a formfield with the name: undefined, this is prbably not found
Roelf is offline   Reply With Quote
Old 10-08-2003, 08:39 PM   PM User | #3
btcodeman
New to the CF scene

 
Join Date: Sep 2003
Location: Liverpool
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
btcodeman is an unknown quantity at this point
Quote:
Originally posted by Roelf
in this line:

var v_fldvalue = Request.Form(v_fld);

you try to enter the value from a posted (method = post) formfield into variable v_fldvalue. The fieldname you are querying is stored in the variable v_fld. As far as i can see in your code, this variable is not filled with a value, so it is undefined. i think it is trying to look at a formfield with the name: undefined, this is prbably not found
Sorry typo error by myself - should read as :-

var v_fldvalue = Request.Form(v_fldname);

With the above the correct variable is being referenced but the <% ASP %> section below cannot read the value - why is this ?? Ideas appreciated..
btcodeman is offline   Reply With Quote
Old 10-09-2003, 06:18 AM   PM User | #4
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
is your form POSTed or do u use method="GET" in the form tag

btw, are you trying to execute a piece of asp-code a few times by using a client side for loop? That will not work!!
Roelf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:57 PM.


Advertisement
Log in to turn off these ads.