PDA

View Full Version : Post and Variables


steveg
10-23-2002, 11:07 AM
Ok, now I'm not sure if this is possible but here goes -

I have a form that is being posted to a new page using the POST method.

now I need to dynamically get the values in the post into session variables.

ie

<INPUT TYPE='TEXT' NAME ='PATNO' SIZE='41' VALUE='A123'>

needs to go to

session("PATNO") = "A123"

The main problem here is that it must be totally generic because the number of posts will change and the variable names will change all the time.

any ideas would be greatly appreciated, thanks

Steve.

Mhtml
10-23-2002, 12:58 PM
session("PATNO") = Request.form("PATNO")

raf
10-23-2002, 01:58 PM
The main problem here is that it must be totally generic because the number of posts will change and the variable names will change all the time.


i think you best create an array with the fieldsname and value in +
use a "for each element in arrayname next" statement to name and populate the session-variables.

whammy
10-24-2002, 12:55 AM
I'm not sure exactly what you're trying to do, but you might want to put the whole "Request.Form()" collection into the session variable (or even better yet, look up Scripting.DictionaryObject on http://www.w3schools.com perhaps?), using "for each item in Request.Form()..." and then parse it.

Actually you can find some good examples of that by typing in:

"for each item in Request.Form()"

on Google.

Here's one example... they use it for debugging, but the uses for putting a bunch of stuff into one string or whatever should be obvious:

http://www.4guysfromrolla.com/ASPscripts/PrintPage.asp?REF=/webtech/021099-1.shtml

Hope this helps, since you were unclear on your motives and end results. Actually, reading raf's post, I had basically the same ideas... but it all really depends, like I said, on what you're trying to accomplish.

Can you give your requirements to us in English?