Re: buton names
It worked on normal submit buttons but problem on image submit button. I couldn't manage to work it with image submit buttons. Fot example if their 2 image submit buttons as : input type=image border=0 name=button3 value=This is button 3 src=c:\windows\desktop\house.gif width=100 height=50brbrbr input type=image border=0 name=button4 value=This is button 4 src=c:\windows\desktop\debugreport.jpg width=100 height=50 cgi cannot get the names of these? Must i use other module? thanxs bye - Original Message - From: Brett W. McCoy [EMAIL PROTECTED] To: GsuLinuX [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, February 14, 2002 6:26 AM Subject: Re: buton names On Wed, 13 Feb 2002, GsuLinuX wrote: 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 } You have two submit buttons, each with the same name but a different value. print submit(-name='action', -value='Add' ); print submit(-name='action', -value='Delete' ); They won't go to different CGI scripts, but a single CGI script will have those button names (you should give them values also) as parameters, so you can take different action based on the button names. I would use a hash of coderefs to handle this: my $action_button = param('action'); my %actions = ( 'Add' = \add 'Delete' = \delete ); $action($action_button)-(); sub add { .. } sub delete { }; Or, alternatively, you could use CGI::Application to accomplish this (which also uses a hash of coderefs to handle multiple actions). -- Brett http://www.chapelperilous.net/ Air is water with holes in it. -- 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]
Re: buton names
On Thu, 14 Feb 2002, GsuLinuX wrote: It worked on normal submit buttons but problem on image submit button. I couldn't manage to work it with image submit buttons. Fot example if their 2 image submit buttons as : input type=image border=0 name=button3 value=This is button 3 src=c:\windows\desktop\house.gif width=100 height=50brbrbr input type=image border=0 name=button4 value=This is button 4 src=c:\windows\desktop\debugreport.jpg width=100 height=50 cgi cannot get the names of these? Must i use other module? The problem with image buttons is that they return name.x and name.y (with the corrdinates of where they were clicked) to your CGI script, so you will need to find out which image was clicked that way. You could do something like (using CGI.pm): use CGI; my $q = new CGI; my %params = $q-Vars(); #put all params into hash my $button; foreach(keys %params) { if(/(.*)\.x) { $button = $1; } } -- Brett http://www.chapelperilous.net/ QOTD: If you're looking for trouble, I can offer you a wide selection. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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
RE: buton names
You're asking for a peck of trouble. One solution I would consider is JavaScript's onSubmit() method. -Original Message- From: GsuLinuX [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 2: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]
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]
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]
RE: buton names
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]
Re: buton names
thanx from Istanbul:) i'll try it... funky - Original Message - From: Hanson, Robert [EMAIL PROTECTED] To: 'GsuLinuX' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 14, 2002 12:03 AM Subject: RE: buton names 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]