Professional Web Applications Themes

how to pass an array of data with hidden fields or cookies? - ASP Database

Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input type="checkbox" name=ck id=ck <input type="checkbox" name=ck id=ck .... <input type="checkbox" name=ck id=ck </form> I made a function which detect the checked products and which put those productnumbers into an array, suppose prod[i]. That's ok. ...

  1. #1

    Default how to pass an array of data with hidden fields or cookies?

    Hi,

    i know how to pass a value from Javascript to ASP with a hidden field into a
    form and submitting it, or with cookies, but here i have to pass a lot of
    data in an array.

    There is a list of product the visitor can order by clicking one or more
    checkboxes. I made a form containing input with type "checkbox" like:
    <form>
    <input type="checkbox" name=ck id=ck
    <input type="checkbox" name=ck id=ck
    ....
    <input type="checkbox" name=ck id=ck
    </form>

    I made a function which detect the checked products and which put those
    productnumbers into an array, suppose prod[i]. That's ok.
    But now, how can i pass that array to another ASP-page, where those
    productnumber must be put into the database? It's not realistic to make a
    lot of hidden fields, certainly because the amount vary each time.

    Thanks for any hints
    Fred



    Fred Guest

  2. #2

    Default Re: how to pass an array of data with hidden fields or cookies?

    Fred wrote: 

    Use join() to create a delimited string from the array, and write it into a
    hidden textbox: 


    doentGetElementById("txtHidden").value = prod.join(",")

    Then, in the ASP to which the above form is posted, use Split() to create
    your array:

    <%
    dim arChecks
    arChecks=Split(Request.Form("txtHidden"),",")
    %>

    Actually, this task can be made simpler. Try out this small asp page which
    posts to itself:

    <%
    Response.Write Request.Form("ck") & "<BR>"
    %>
    <HTML>
    <BODY>
    <form method="post">
    <INPUT type="checkbox" id=ck1 name=ck value="1">
    <INPUT type="checkbox" id=ck2 name=ck value="2">
    <INPUT type="checkbox" id=ck3 name=ck value="3">
    <INPUT type="checkbox" id=ck4 name=ck value="4">
    <INPUT type="submit" value="Submit" id=submit1 name=submit1>
    </form>
    </BODY>
    </HTML>


    By giving the same name to each of the checkboxes, you enabled the page that
    processes the submission to treat them as a single unit. You can also do
    this:

    <%
    dim key
    for each key in Request.Form("ck")
    Response.Write key & "<BR>"
    next
    %>



    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  3. #3

    Default Re: how to pass an array of data with hidden fields or cookies?

    Please don't multipost. I've already replied to this question over at
    ..asp.db (where it was somewhat offtopic, having nothing to do with
    databases). Posting the question
    here as well did not increase your chances of getting an answer (most of us
    subscribe to both groups). On the contrary, if somebody had taken his time
    to answer it here, only to find that it was already resolved in the other
    group, that person may have been annoyed enough to ignore any future posts
    from you, thereby decreasing your chances of getting help in the future.


    There are times when you will not be sure which group is most appropriate
    (again, this was not one of them), and you will want to post a question to
    both groups. In that situation, you should use the cross-posting technique,
    rather than posting the same message multiple times. To crosspost, put
    a semicolon-delimited* list of the newsgroups to which you wish to post in
    the To: header of your post and post it once. It, and any replies to it,
    will appear in all the newsgroups in your list. So, if I reply in .asp.db,
    my reply will also appear here in .asp.general.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  4. #4

    Default Re: how to pass an array of data with hidden fields or cookies?

    Oops. I just realized that you crossposted this message instead of
    multiposting it. Please ignore my previous reply (which I have just
    attempted to cancel). Instead, I would like to offer the thought that this
    question has nothing to do with databases and therefore probably should not
    have been crossposted to the .db group. However, this breach of netiquette
    is not nearly as extreme as a multipost would have been.



    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  5. #5

    Default Re: how to pass an array of data with hidden fields or cookies?

    Thanks

    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:phx.gbl... 
    not 


    Fred Guest

Similar Threads

  1. Pass value of hidden fields in Gridview to SQL parameter
    By Hennie in forum ASP.NET Data Grid Control
    Replies: 4
    Last Post: June 29th, 07:18 PM
  2. Looping through only hidden fields
    By timsilva in forum Macromedia ColdFusion
    Replies: 4
    Last Post: April 18th, 03:15 AM
  3. CF7 Flash Hidden Fields
    By drew_falkman in forum Coldfusion Flash Integration
    Replies: 2
    Last Post: April 7th, 07:54 PM
  4. Cookies & Hidden Image
    By Nicole in forum PHP Development
    Replies: 13
    Last Post: September 7th, 04:12 AM
  5. [PHP] Too Advanced? Cookies & Hidden Image
    By Chris Shiflett in forum PHP Development
    Replies: 0
    Last Post: September 3rd, 10:24 PM

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