Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Data Passing to Another if error 1

Status
Not open for further replies.

ArkeyArk

Programmer
Nov 13, 2000
6
US
Is there a way to dynamically pass data from one form to another.
Here is what I want to happen.
User fills in a form (enter new userid and pass). >
They Click Submit. >
The processing page first checks to make sure that Userid does not exist.
if it does not it continues to process the rest of the form. >
Else it passes all the information back to the referring URL with an error message. >
I dont want to keep saying Request("this and that"); I want to make this dynamic so it passes. Is there an array or some way to pass the entire contents of a form onto another.

I want to use this script in many places where the forms differ and I want a standard error script for this, any hints, clues, pointers, thank you in advance.
Arkey
 
The way to handle dynamic amounts of data being passed is to use a FOR loop.

If you don't care about ordering then what you can use is:

Code:
FOR EACH objItem IN Request.Form
  'do something
NEXT

if you worry about data ordering i.e. theorder in which it is enetered on the form , then use the following

Code:
FOR intCounter = 1 to Request.Form.Count
  'do something
NEXT

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
I just don't understand what the objItem. Is that an array of all the form elements that have been passed. How can I use that without using the FOR EACH. Im using ASP(JSCRIPT) so the syntax is different, i just couldnt find any documentation on this objItem coming from Request.Form
Arkey
 
objItem is a variable that you have declared thata isused to walk along the collection. it is a bit like a pointer. If you have use pointers to walk a long arrays in C then its a bit similar, except that what you get is the key/value pair in the Collection. Actually you get the key and then you use the key to get at the value.

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
the objItem would be used like this:

FOR EACH objItem IN Request.Form
Response.Write objItem & " = " & Request.Form(objItem)
NEXT
 
Okay I got that much but in Jscript there is no

FOR EACH XXX IN XXX

does anybody know of how to achieve this in JSCRIPT(not javascript but MS ASP JSCRIPT)

The code is exactly what I need but I have had hell trying to figure out how to make the equivalent code.
Anybody?
Arkey
 
How 'bout

for (var i = 1; i < Request.Form.Count; i++){
//do something
}

(off the top of my head)
Assumes array starts at 1 not 0 (can't remember at moment)
 
Sorry, I just can seem to get my point across....

I know how to set up a for loop. My question is what to do in the //do something. I thought objItem was a built in function but its not its user defined, but doesnt help me, if I can do a count (request.form.count) what property do I use to access the names and values of the form fields(if any, im not talking about request(&quot;xxx&quot;)).

This for loop is great but how am I supposed to iterate through the form fields. Remember I have no idea how many form fields there are.

Maybe we'll take a different route, how about this, Im gonna give you an example:

Example:(A form containing an &quot;unspecified&quot; number of fields is passed to a processing page. This processing page must now &quot;Write Out&quot; all the elements in the form that has been passed. Keep in mind that you have no idea how many form fields are being passed. Please use JScript.)

I would just like to put this thread to rest. I don't know any other way I can describe what I'm looking for.

I really do appreciate your help, you guys are awesome.
Thank You,
-------------------------------------------------------
&quot;Even A Stopped Clock Tells the Right Time Twice A Day&quot;
--Anonymous

Arkey Ark
Web Designer, Programmer
 
Ahh!!!,

objItem is just an object varaible that you use to reference an entry in the Request.Form collection.
Each entry in the Request.Form collection has two properties - item and value.

To get the name of the field you use objItem.Item or just objItem, to get at the value for that field you use objItem.Value

However, in the //do something bit in the final example posted you would probably use the following:

Code:
Request.Form(i).Item

and

Code:
Request.Form(i).Value

Hope this helps. It really is quite straight forward. James Culshaw
jculshaw@active-data-solutions.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top