Gossamer Forum
Home : General : Perl Programming :

target redirect

Quote Reply
target redirect
I've created this small search script for my webpage which allows my visitors to search the largest search engine from my webpage. Now I'm trying to make this feature so they can choose to open the search results in a new window.

I've tried several methods, but so far nothing has worked the way I want it to.

Here's the field:
<form action="search.cgi" method="post" name="search" target="_blank">
<input type="text" size="16" name="search">
<select size="1" name="select">
<option value="google">Google</option>
<option value="altavista">Altavista</option>
<option value="lycos">Lycos</option>
<option value="yahoo">Yahoo</option>
<option value="kvasir">Kvasir (NOR)</option>
</select> Open in a new window? <input type="checkbox" value="1" name="window" checked="checked"><input type="submit" value=" Search now! "></form>

As you see, I've added a target="_blank", which of course would be the easy method. But then they can't choose.
I'll show you an example of the script code:
if ($FORM{'window'} eq "1") {
$target = "TARGET=_blank";
else {
$target = "TARGET=self";

if ($FORM{'select'} eq "google") {
print "Refresh:2; URL=$url1 $target\n\n";
print "<body bgcolor=$bgcolor text=$text>";
print "Searching..This may take some seconds.";
print "</body>";

I'm not sure if it's possible to include a TARGET inside a refresh?! Could I do this using the Location method or? Maybe I have to change the form to get it right? I'm not sure.

Any advises?

- perlman