[thelist] ASP: help with forms and ampersand
Michael Galvin
mpgalvin at eircom.net
Sat Oct 21 18:22:08 CDT 2000
I have a form on my page, which is posting to an asp page.
I found tonight that I had problems if the user used a character like &, or
' in any of the fields on the form, so I changed the method of the form from
GET to POST.
Problem solved!
Unfortunately, I've now opened up a world of pain for myself.
The full story: I have a form with 10 elements on it, but only the first 3
are mandatory. If the user fills in the first 3 AND NO MORE, he should go
directly to the "thank you" page. If he fills in any more than the first 3,
I want to go to an interim page which asks them for even more information
(the client's idea)
So, originally, I had the form GETting the data, and then I used a bit of JS
to redirect the browser based on whether the user had entered data for the
first 3 fields only or not.
Now, being clever, I decided to create a variable which consisted of the
previous form's field names with their passed values, so
"name=Michael&address=Dublin&..." etc. I tacked this on to the name of the
page I was redirecting to. Worked like a charm, but this is just recreating
the function of a GET. My problem with the ampersands is back!
(If name is "Michael&Miriam", it only picks up "Michael", in case it's not
clear what my problem is)
I should probably add that the form is on a page called you.asp, and it
posts to you.asp so that the same page can validate and stuff. Basically,
if life was beautiful, I'd want to post to 3 different pages depending on
what the user puts in the form.
So, is there a way around this? I'm pretty sure there's a MUCH better way
of handling all this, and that there are people at home right now rolling
their eyes at the amatuerness (word?) of it all, but I'm tired and I want to
go to bed.
Can you help?
TIA
Michael
More information about the thelist
mailing list