473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 21 '05 #1
4 5391
Fred wrote:
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.
Use join() to create a delimited string from the array, and write it into a
hidden textbox: 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.

documentGetElem entById("txtHid den").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("t xtHidden"),",")
%>

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

<%
Response.Write Request.Form("c k") & "<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("c k")
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"
Jul 21 '05 #2
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"
Jul 21 '05 #3
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"
Jul 21 '05 #4
Thanks

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:u8******** ******@TK2MSFTN GP09.phx.gbl...
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"

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
31543
by: John | last post by:
I would like to pass array variables between URLs but I don't know how. I know its possible with sessions, but sessions can become useless if cookies are disabled. I have unsuccessfully tried using post and get methods. Thank you John
11
2544
by: Colin Steadman | last post by:
Hope this makes sense! I'm building an ASP page which allows uses to add items to an invoice via a form, ie: Item No Part No Order No Quanity Units Price VAT ------- ------- -------- ------- ----- ----- --- .... ... ... ... ... ... ... <Add item> <Submit>
3
2398
by: agb | last post by:
How can I send a string array to another aspx page?
7
4451
by: Andy | last post by:
Hi, I have a complicated question that I'm hoping someone can help me out with. I have a webpage that contains a plug-in. This plug-in can communicate/pass data with the webpage that contains it via javascript. What I need to be able to do is take that data passed via javascript and, using vb.net as the code behind language, send it to a database without posting it because when I post, the plugin is reloaded and starts at the beginning....
3
2117
by: HockeyFan | last post by:
I know that <input type="hidden" fields are used within a form, but do <ASP:HiddenField s have to be in a form to be used? I've got a VB-based (codebehind) that catches the click event of a button on the page, does some processing, populates the <ASP: hidden fields, and then I need to redirect to another page, where I want access to these fields. I suspect that these have to be inside a form, but figured I should ask. I'd use a Cache or...
2
2565
by: Jeff | last post by:
....still new to .net 2005 using VB. Do I understand correctly that the value of a session variable is actually stored in the server's ram, but relies on the asp.net session ID cookie that temporarily is placed on the client's machine until the session ends? ...so that you can't use session variables if the client has disabled cookies on their browser? So, this makes session vars much more secure than hidden fields, which are transmitted...
19
248253
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
3
2400
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains Home, Retail Contact Us
9
30136
by: nicnac | last post by:
Hi, I'm self learning javascript - so any pointers are welcomed!! I have an issue passing a form and array from one function to another. I tried many variations ! I can't get this to work and I can't get this issue out of my head !!!! So I'm obviously missing something really simple and can't see it or it can't be done with my limited knowledge. I know that I can use a cookie to store the array as string - I have this working but...
0
9790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9779
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5247
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2612
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.