ASP and passsing data between pages

They have: 330 posts

Joined: Apr 2000

Please correct me if / where I'm wrong.

The 3 ways to pass data between pages when using ASP/javascript is:
1. Form
2. Sessions
3. QueryString

1. When using a form including a Select box only how could I pass 2 pieces of information to the next page?

2. I really don't want to use sessions any more than I have to and I already have 1 being sent on an unrelated issue.

3. I get an error when the querystring includes spaces so that doesn't seem to be the best way to pass statements.

The 2 pieces of information I am wanting to send to the next page is:
1 - Autonumber associated with a statement.
2 - The statement

Thanks for any help.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

if your going to be passing anything via the querystring, be sure to escape everything.
ASP: Server.URLEncode(string)
JS: escape(string)

You can also pass values between pages via cookies.

If you want to pass multiple values in one form item, try mixing the value. Here is some Quicky Code (untested). I haven't played with ASP for a while, so there may be a better way to do this.

## HTML PAGE ##
<select name="blah">
  <option value="id|statement">option1</option>
</select>

## ASP PAGE ##
<%
tmp_array = split(Request.Form("blah"), "|")
id = tmp_array(0)
statement = tmp_array(1)
%>
'
curious.. why are you passing an autonumber?

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 330 posts

Joined: Apr 2000

Thank you very much, you have answered my question. After trying it I found it was impossible to do it the way I wanted so I had to create a little bit of sloppy code to make it work. I will try to explain it and please tell me if you can think of a better way.

The application is a Decision Tree for employees in a technical support department. Once the employee chooses the error the customer is getting he is then faced with Yes No questions and troubleshooting steps 1 at a time to walk him/her through the processes. Each step is then saved into a session seperated by a comma. The rep can then hit a "Copy Notes" button which copies everything done into the clipboard so he/she can paste it into the internal ticketing system.

The way I display the notes before being copied is by splitting them into an array and writing them into a table on one side of the screen. Every step taken creates another step which adds to the notes. Because I need the rep to see the notes, not the autonumber which is how I could find the associated troubleshooting steps. I am forced to pass 2 pieces of data (Autonumber & Statement) to make that happen.

I ended up passing the notes as "Autonumber, Statement, " and then I am running an if statement to check for a numeric value for each node of the array. If it is a number I am creating the link and not displaying the number, otherwise I am just writing the step taken.

I'm sorry if this didn't make much sense but like I said I'm not good at explaining this.

Has anyone created something like this before? Is there anything I'm missing?

Thanks for your help.

sersun's picture

They have: 32 posts

Joined: Aug 2001

I don't know for sure if this answers your question, but I performed a hack that lets you pass 2 vars through one form element.

Here's the example:

Illinois

The "&" adds the second value pair: state_id=66, so the resulting target becomes:

nextpage.phtml?state_name=Illinois&state_id=66

You could theoretically pass as many values as you want, all throught the one select element.

sersun

They have: 330 posts

Joined: Apr 2000

Thank you very much. I have this application working right now but that is a great idea. I will use that in the future.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.