[thelist] CGI Form Submit in Javascript
Keith
cache at dowebs.com
Wed Dec 19 18:36:04 CST 2001
Tom
> the submit), and have it POST the results as a Query
> String which I can pass along to another URL designed
> to handle the results.
It's hard to tell what you want to do here. If you want the form to be
submitted via POST to /cgi-bin/ipoform_engine.cgi" and then sent
via a query string to whereever.com/Engine.asp? you need
something in the poform_engine.cgi that redirects to Engine.asp
such as
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
$url = qq~http://www.whereever.com/Engine.asp?$input~;
print "Location: $url\n\n";
or, if you are manipulating the data in routines on
poform_engine.cgi and have the data already in an associative
array (let's call it $FORM) then you need to build a query string with
while(($name,$value)=each(%FORM)){
$query .= $name."=".$value."&"~;
}
$url = qq~http://www.whereever.com/Engine.asp?$query~;
chop($url); #remove last &
print "Location: $url\n\n";
If you instead want the form sent as a query string to
whereever.com/Engine.asp? without bouncing through
poform_engine.cgi at all simply change the method on your form
from POST to GET and it happens automatically, in the format
http://www.whereever.com/Engine.asp?config=tshirt&first_name=Jo
hn etc.
Technically you can change the destination of a form with javascript
using document.form[x].action="someother.cgi" and even attach a
query string composed by the javascript. But, if you do, and if the
method is POST, the destination is going to recieve a query string
AND all of the name/value pairs in STDIN also. The fact that a
POST method can also carry a query string attached to the action
is usefull in telling a script something (such as the cycle) about the
information posted but it doesn't look like that is your intent here.
BTW it's a good idea to always include a value="" on a form
element that recieves user input. If the user has a space in their
input the lack of quotes will pick up only the first part of their input,
it's a big world out there and some last names have two words to
them.
keith
More information about the thelist
mailing list