Professional Web Applications Themes

Retrieving values from dynamic form with ASP - ASP Database

Hello, I hope you can help me with this issue... I need to be able to retrieve the values in a form that is dynamically created. I have the following in the form, for example: First Name Last Name Date Ken Smith 9/30/2004 Jim Jones 9/30/2004 Mike Alder 9/30/2004 Everything in the form, except the header, is entered by the user. I need to be able to retrieve the values entered in another asp page. The asp page is jscript. I have the function in the asp page below: function getName(){ var a = Request.Form("FirstName"); var b = Request.Form("LastName"); var ...

  1. #1

    Default Retrieving values from dynamic form with ASP

    Hello,
    I hope you can help me with this issue...
    I need to be able to retrieve the values in a form that is dynamically
    created.
    I have the following in the form, for example:

    First Name Last Name Date
    Ken Smith 9/30/2004
    Jim Jones 9/30/2004
    Mike Alder 9/30/2004

    Everything in the form, except the header, is entered by the user.
    I need to be able to retrieve the values entered in another asp page.
    The asp page is jscript.
    I have the function in the asp page below:
    function getName(){
    var a = Request.Form("FirstName");
    var b = Request.Form("LastName");
    var c = Request.Form("Date");

    some code goes here to loop through the values
    and add them to a table...

    }

    Is there anyway I can do this?
    Please advise.
    Thanks,
    Consuelo :-)
    Consuelo Guest

  2. #2

    Default Re: Retrieving values from dynamic form with ASP

    Will all the form fields be named Firstname, Lastname, and Date, or will it
    be more like Firstname1, Firstname2, Firstname3... Lastname1, Lastname2....
    and so on?

    And when this form is created dynamically, is this not done so from your
    code on another ASP page?

    Ray at home

    "Consuelo Guenther" <microsoft.com> wrote in
    message news:com... 


    Ray Guest

  3. #3

    Default Re: Retrieving values from dynamic form with ASP

    yes, all the fields are Firstname, Lastname, and Date. but the values will
    change based upon a selection prior to loading this page. next time, the
    values might be
    First Name Last Name Date
    Kim Jones 9/17/2004
    Art Mitt 9/18/2004
    Drew Oslo 9/16/2004

    Yes, another code in the same asp page creates and displays these values
    based upon a selection criteria from a drop down combo box.

    "Ray Costanzo [MVP]" wrote:
     
    >
    >
    >[/ref]
    Consuelo Guest

  4. #4

    Default Re: Retrieving values from dynamic form with ASP

    All the the actual <input type="text"> have the same name value? (Well,
    three different ones, firstname, lastname, and date.)

    If you do it this way, how are you going to identify which firstname goes
    with what last name, etc.? I don't think that you can do that, in a
    guaranteed way. If you just loop through the Request.Form collection, there
    is no guarantee that the fields will be returned in the same order that they
    appeared on the page. So, you'll have a bunch of first names, last names,
    and dates, but no way of wiring them all up to their respective partners.
    If that doesn't matter, then it's not a problem, but I suspect that you are
    not interested in just getting a pile of last names, a pile of first names,
    and a pile of dates that don't relate to each other.

    So, one thing that you can do is change the page that generates the form
    fields and give them each unique names, i.e.

    var i = Request.Form("numberOfPeople")
    for (j = 1; j <= i; j++) {
    Response.write("<input name=\"txtFirstname" + j + "\"
    type=\"text\">\n");
    Response.write("<input name=\"txtLastname" + j + "\" type=\"text\">\n");
    Response.write("<input name=\"txtDate" + j + "\"
    type=\"text\">\n<br>\n");
    }
    Response.write("<input name=\"count\" type=\"hidden\" value=\"" + i +
    "\">");


    Then, on the page that processes the data, you can grab the value from the
    hidden input, "count" and know how many groups of people to loop through,
    i.e.

    var sFirstname, sLastname, sDate
    var i = Request.Form("count")
    for (j = 1; j <= i; j++) {
    sFirstname = Request.Form("txtFirstname" + j);
    sLastname = Request.Form("txtLastname" + j);
    sDate = Request.Form("txtDate" + j);
    Response.Write("Person " + j + ": " + sFirstname + " " + sLastname + " " +
    sDate + "<br>");
    }


    If you use a method like this, just be sure not to take anything for
    granted - always assume all input is invalid.

    Ray at home

    "Consuelo Guenther" <microsoft.com> wrote in
    message news:com... 
    >>
    >>
    >>[/ref][/ref]


    Ray Guest

Similar Threads

  1. Retrieving values from DataGrid row before update
    By greenb in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: May 14th, 03:33 PM
  2. how to reset a form with dynamic default values
    By zu in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: November 30th, 04:17 PM
  3. retrieving multi-select form values
    By Hank Tt in forum PHP Development
    Replies: 2
    Last Post: July 31st, 06:14 PM
  4. [PHP] retrieving form checkbox values
    By Marek Kilimajer in forum PHP Development
    Replies: 0
    Last Post: July 17th, 09:57 AM
  5. retrieving form checkbox values
    By Caspar Kennerdale in forum PHP Development
    Replies: 2
    Last Post: July 17th, 09:34 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139