[thelist] ASP: help with forms and ampersand

Warden, Matt mwarden at odyssey-design.com
Sat Oct 21 19:33:55 CDT 2000


> I found tonight that I had problems if the user used a character like &,
or
> ' in any of the fields on 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.

Seems to me that the best thing for you to do is re-architect how you're
doing things. You really shouldn't be fooling with the action of a form. You
should submit to a single page, which then redirects to specialized pages if
you want. Personally, I'd use post and then a single form-handling script.
There would be a SUB for each possible thing to display to the page (like
DisplayThankYou(), DisplaySecondForm(), etc.)

However, the *easiest* thing for you to do is to just use JS's escape()
function around your values when you pass-along those form values:

url += "?myvar=" + escape(document.form.element.value);

escape() is similar to Server.URLEncode (I think the only difference is that
it encodes spaces as +'s instead of the correct %20).

hth,

--
mattwarden
mattwarden.com





More information about the thelist mailing list