Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Location
    Liverpool
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>
    %>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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
    I am the luckiest man in the world

  • #3
    New to the CF scene
    Join Date
    Sep 2003
    Location
    Liverpool
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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!!
    I am the luckiest man in the world


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •