954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to pass multiple values in table to another form

Dev't Tool: Visual C# 2003 and Javascript
System Type: Web Application

One requirement of the system is to dynamically create a table on client-side (Javascripting using createElement method.) The table has textboxes inside each cell.

a few sample code:

for (i = 0; i < 4; i ++) // four columns
{
textBoxes = document.createElement("INPUT");
textBoxes.type = "text";
textBoxes.id = "txt1";
textBoxes.name = "txtA";
cell.appendChild(textBoxes);
}


These are my options to get the values:
1. Through querystring -> but not possible because there are many values to be passed.
(sample: WebForm2.aspx?value1=&value2)

2. Also tried getting it by Request.Form["txtA"]
I can get the values but it is comma delimited. I cannot get exact data when my input has "," in it.
(sample: Input1 = "a,b"; Input2= "c"; Request.Form["a,b,c"])
if to be split, 3 values will be returned instead of 2.

Maybe there's another option that you can suggest so I can retrieve those multiple data.

One more thing, I would like those data to be on one-time retrieval because in the INSERT process, I plan to include them on a loop inside a TRANSACTION statement so if one record encountered an error, all will ROLLBACK.

cubekid
Newbie Poster
12 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

As per the specification, in a HTML document, the ID attribute must be unique. Assign a different ID and NAME to each INPUT element. Don't use GET, use POST for sending your form data.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

Thanks for the reply. I solved the problem by using my 2nd option which I stated before (Request.Form["txtA"]).

I just created a function that replaces "," with "%2c" so that if a user tends to input a value with ",", the parser will not treat it as a delimiter, thus splitting the returned value accurately.

cubekid
Newbie Poster
12 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

There is a better way of doing the same thing which encodes the URI component to avoid all such problems:

encodeURIComponent("a,b,c"); // a%2Cb%2Cc
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You