--- Henk van Ess <[EMAIL PROTECTED]> wrote: > Dear all, > > They told me that this forum teaches Perl in a friendly atmosphere, so I > hope you can help me. My name is Henk van Ess and I run www.voelspriet.nl, a > Dutch site about searchengines (non-commercial). > > I'm busy with a form for searching all kind of special operators in search > engines and I want to do that job with radioboxes. > > One radiobox should give the following output:
I'm not sure if you mean radion *button* or *check* box. I am guessing the latter, but what I present will work either way. > http://www.google.com/search?q(FIXED VALUE)+(VARIABLE) > > where FIXED VALUE= allintitle: and the VARIABLE is the search term that the > user enters. > > EXAMPLE: > > Say someone searches for the word Perl and checks the radiobox "Search title > only", I will need the output: Without reproducing the rest of your email, I'll cut to the chase :) Unless you use Javascript, you are trying to combine to form parameter values into one and you can't do that directly from the form (that I know of). Here's one way to do this through Perl: #!/usr/bin/perl -wT use strict; use CGI qw/:standard/; use URI::Escape; # if we came from the form, grab the values and create the URL if ( param ) { # get the form data # see perldoc CGI my $_prefix = param( 'prefix' ) || ''; my $_search = param( 'search' ) || ''; # untaint it # see perldoc perlsec my ( $prefix ) = ( $_prefix =~ /^([a-zA-Z\d\s_:]+)$/ ); #create appropriate regex my ( $search ) = ( $_search =~ /^([a-zA-Z\d\s_:]+)$/ ); #create appropriate regex # escape characters with special meaning in URIs # see perldoc URI::Escape $prefix = uri_escape( $prefix ); $search = uri_escape( $search ); print redirect( "http://www.google.com/search?q=$prefix%20$search" ); } # otherwise, print the Web page else { print header; print <<END_HTML; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Test page</title> </head> <body> <form action="test.cgi" method="get"> <input type="checkbox" name="prefix" value="allintitle:" /> All in title<br /> <input type="text" name="search" /> <input type="submit" name="Submit" /> </form> </body> </html> END_HTML } It works this way: if we have no form parameters, print the Web page. If we have form parameters, grab them, untaint them, convert any characters that may have a special meaning in a URL, and the do a redirect. All relevant section have pointers to the correct documentation. Obviously, you'll need more than this, but I hope this is a good starting point. Hope this helps. Cheers, Curtis "Ovid" Poe ===== "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __________________________________________________ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]