Oh, I see.  Errr... I agree with Camilo.

If you really wanted to do it that way you could have the script redirect to
the second script  Like this:

if ( param('button1') ) {
    print "Location: somescript.cgi?$params\n\n";
}
elsif ( param('button2') ) {
    print "Location: anotherscript.cgi?$params\n\n";
}

You need to pass the params though as part of the URL though which limits
you to about 1000 characters of data, and you also need to URL encode it.

You could also use the do() function, but that is also a little messy.  It
might look like this:

if ( param('button1') ) {
    do('somescript.cgi');
}
elsif ( param('button2') ) {
    do('anotherscript.cgi');
}

Either way though, it would be messy, and I don't recommended either.
....But sometimes that is your only option, like if JavaScript was not
allowed or you knew that many users would not have JavaScript available
(unlikely, but stuff happens).

Rob

-----Original Message-----
From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 4:56 PM
To: Hanson, Robert; 'GsuLinuX'; [EMAIL PROTECTED]
Subject: RE: buton names


I understood his request differently, that he wanted to send the parameters
to different scripts depending on the submit button pushed.

-----Original Message-----
From: Hanson, Robert [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 3:44 PM
To: 'GsuLinuX'; [EMAIL PROTECTED]
Subject: RE: buton names


You can do it just like that.

Given this HTML form:

<form action="/cgi-bin/test.cgi">
<input type="submit" name="button1" value="This is button 1">
<input type="submit" name="button2" value="This is button 2">
</form>

You can use this script:

#!/usr/bin/perl

use CGI qw/:standard/;

print header();

if ( param('button1') ) {
    print "Button 1 was pushed!";
}
elsif ( param('button2') ) {
    print "Button 2 was pushed!";
}

Camilo, why is that a problem?  Is there inconsistencies between how
browsers handle that info?  I don't know of any problems with it offhand,
and I have used it in the past (a long, long, time ago... nothing recent).

Rob

-----Original Message-----
From: GsuLinuX [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 3:22 PM
To: [EMAIL PROTECTED]
Subject: buton names


Hola! , 

There are 2 submit butons under my form and the information entered to the
form will be send to different cgi's. How can i do this?

One idea i thougt is to give names to the buttons and in the cgi :
if buton name is "buton1"
{ code1 }
if buton name is "buton2"
{code2 }

how can i do that if it's possible

thanx
funky
Istanbul


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to