Home > Archive > PERL Programming > July 2004 > help with perl search
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
help with perl search
|
|
| Anthos 2004-06-29, 3:57 pm |
| Hello, I downloaded a search script (open source), that seems the most
simple and customizable among all I scrutined so far (indeed, there are few
choices), and I was able to modify the most of easier features in order to
match my requirements, though since two days so far I'm stuck with the
following commands:
print "$display\n";
}
print "<center><form name=\"more\" action=\"$thisScript\">\n";
if ($start>0) {print "<input type=\"submit\" name=\"back\"
value=\" \">\n";}
if ($end<@results) {print "<input type=\"submit\" name=\"forward\"
value=\" \">\n";}
print "<input type=\"hidden\" name=\"from\" value=\"$start\">\n";
print "<input type=\"hidden\" name=\"log\" value=\"false\">\n";
foreach $key (keys %FORM)
{
$val=$FORM{$key};
next if (($key eq "back") or ($key eq "forward") or ($key eq "from"));
print "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n";
}
print "<\/form><\/center>\n";
}
else {print "<center><img border='0'
src='http://www.yoursite.com/images/msg_errorsearch.gif'><br>\n"}
I wish to substitute the pesky form buttons with images or text either, but
I wasn't able to. How to? Time ago I heard casually about kinda javascripts
that do so that a submit button can be triggered by a text or image link,
but I wasn't able to find any (problem with thinking any decent keywords for
google). Can anyone help me please?
If that suite of commands doesn't lead to any solutions of modify, in the
case it depends from some other rows on the script, I can also privately
send the script to have a complete view of it.
| |
| Joe Smith 2004-06-29, 3:57 pm |
| Anthos wrote:
> I wish to substitute the pesky form buttons with images or text either, but
> I wasn't able to. How to?
1) Create a plain HTML page that looks the way you want.
2) Modify your perl script to output that.
You need to find a good HTML reference and look at *all* the options
for <INPUT>.
| |
| Purl Gurl 2004-06-29, 8:56 pm |
| Anthos wrote:
(snipped)
> print "<center><form name=\"more\" action=\"$thisScript\">\n";
> if ($start>0) {print "<input type=\"submit\" name=\"back\"
> value=\" \">\n";}
> I wish to substitute the pesky form buttons with images or text either
<INPUT TYPE=\"IMAGE\" SRC=\"http://www.purlgurl.net/~choctaw/graphics/next.gif\" NAME=\"next\" VALUE=\"forward\" BORDER=\"0\">
However, you may expect some problems. Older browsers, such
as Netscape 4.x series, old MSIE, do not recognize IMAGE
as a submit tag, disallowing use of name / value pairs.
Your "next" and "back" name value pairs will be lost.
Newer browsers do recognize IMAGE as a submit button and
will pass name / value pairs.
A work around is to print your IMAGE tag submit button
without name / value pairs, then add a input type hidden
tag to pass your name / value pairs as needed.
if ($end<@results) if your "forward" condition, then print
<INPUT TYPE=\"IMAGE\" SRC=\"http://www.purlgurl.net/~choctaw/graphics/next.gif\" BORDER=\"0\">
<input type=\"hidden\" name=\"next\" value=\"forward\">
if ($start>0) if your "back" condition, then print
<INPUT TYPE=\"IMAGE\" SRC=\"http://www.purlgurl.net/~choctaw/graphics/back.gif\" BORDER=\"0\">
<input type=\"hidden\" name=\"back\" value=\"return\">
For newer browsers, you can include name / value pairs in
your IMAGE submit button tag.
For older browsers, you cannot and must pass name / value
pairs through a hidden field.
Use an IMAGE submit tag and a hidden field to ensure
all browsers will work correctly as shown in my
dual example above.
There are thousands of "button" graphics all over the net.
Use of Google will return hundreds of hits.
Purl Gurl
| |
| Purl Gurl 2004-06-29, 8:56 pm |
| Purl Gurl wrote:
> Anthos wrote:
(snipped)
Here is a simple cgi script to exemplify
this problem with old browsers and new
browsers. Data will be printed for you
and you can observe different behaviors.
Name this test.pl or edit my script to
change the name to something else, point
your browser to its URL location, then
test with an old browser, observe results,
then test with a new browser, and observe
results. You will see data missing for the
old, data there for the new.
Purl Gurl
--
Each line should be a single line.
Watch out for word wrapping.
#!perl
read (STDIN, $in, $ENV{'CONTENT_LENGTH'});
@in = split (/&/, $in);
foreach $iterate (0 .. $#in)
{
$in[$iterate] =~ tr/\+/ /;
($key, $value) = split (/=/, $in[$iterate], 2);
($value eq "") && next;
$key =~ s/%(..)/pack ("c",hex($1))/ge;
$value =~ s/%(..)/pack ("c",hex($1))/ge;
$in{$key} .= $value;
}
if (!($in{text_box}))
{ $in{text_box} = "Purl Gurl Rocks!"; }
if (!($in{text_area}))
{ $in{text_area} = "Purl Gurl Rocks My Socks Off!"; }
print "Content-Type: text/html\n\n
<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">
<HTML>
<BR><BR>
<FORM ACTION=\"test.pl\" METHOD=\"POST\">
<FONT FACE=\"arial rounded mt bold\" COLOR=\"#000000\" SIZE=\"2\">
<INPUT TYPE=\"IMAGE\" SRC=\"http://www.purlgurl.net/~choctaw/graphics/next.gif\" NAME=\"forward\" VALUE=\"forward\" BORDER=\"0\">
</FONT>
<P>
Change Current Data To Anything You Want:
<P>
<I>Text Box:</I> <INPUT TYPE=\"text\" SIZE =\"20\" NAME=\"text_box\" VALUE=\"$in{text_box}\">
<BR>
<I>Text Area:</I>
<TEXTAREA NAME=\"text_area\" ROWS=\"2\" COLS=\"50\">$in{text_area}</TEXTAREA>
</FORM>
<P>
Text Box Input: $in{text_box}<P>
Text Area Input: $in{text_area}<P>
Button Input: $in{forward}<P>
</HTML>";
exit;
| |
| Anthos 2004-06-29, 8:56 pm |
| "Purl Gurl" <purlgurl@purlgurl.net> ha scritto nel messaggio
news:40E1F39B.E0F93075@purlgurl.net...
> <INPUT TYPE=\"IMAGE\"
SRC=\"http://www.purlgurl.net/~choctaw/graphics/next.gif\" NAME=\"next\"
VALUE=\"forward\" BORDER=\"0\">
<snip>
I already did this for both, but it didn't worked; I wonder whether this
depends from messing up with the chunk alone, or it is due 'cause of it is a
consequence of something else in the script, which initializes the
subsequent form's variables, so that, when attempting to mess with the code,
something gets wrong, e.g. this:
if (@results)
{
$start=$FORM{"from"};
$increment=$FORM{"max"};
$increment=$maxPages if (!($increment));
if ($FORM{"forward"})
{
$start+=$increment;
}
elsif ($FORM{"back"})
{
$start-=$increment;
}
$start=0 if (!($start));
$end=$start+$increment;
$end=@results if ($end>@results);
$no=$start+1;
print "<p><font class='small'>Results from</b>$no<\/b> a
</b>$end<\/b></font></p><p>\n";
for ($i=$start; $i<$end; ++$i)
{
$no=$i+1;
> There are thousands of "button" graphics all over the net.
> Use of Google will return hundreds of hits.
:) I use my own.
| |
| Matt Garrish 2004-06-29, 8:56 pm |
|
"Purl Gurl" <purlgurl@purlgurl.net> wrote in message
news:40E1F5E7.7BD0681B@purlgurl.net...
>
> #!perl
>
> read (STDIN, $in, $ENV{'CONTENT_LENGTH'});
> @in = split (/&/, $in);
> foreach $iterate (0 .. $#in)
> {
> $in[$iterate] =~ tr/\+/ /;
> ($key, $value) = split (/=/, $in[$iterate], 2);
> ($value eq "") && next;
> $key =~ s/%(..)/pack ("c",hex($1))/ge;
> $value =~ s/%(..)/pack ("c",hex($1))/ge;
> $in{$key} .= $value;
> }
>
> if (!($in{text_box}))
> { $in{text_box} = "Purl Gurl Rocks!"; }
>
> if (!($in{text_area}))
> { $in{text_area} = "Purl Gurl Rocks My Socks Off!"; }
>
>
> print "Content-Type: text/html\n\n
> <!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">
> <HTML>
> <BR><BR>
> <FORM ACTION=\"test.pl\" METHOD=\"POST\">
> <FONT FACE=\"arial rounded mt bold\" COLOR=\"#000000\" SIZE=\"2\">
> <INPUT TYPE=\"IMAGE\"
SRC=\"http://www.purlgurl.net/~choctaw/graphics/next.gif\" NAME=\"forward\"
VALUE=\"forward\" BORDER=\"0\">
> </FONT>
> <P>
> Change Current Data To Anything You Want:
> <P>
> <I>Text Box:</I> <INPUT TYPE=\"text\" SIZE =\"20\"
NAME=\"text_box\" VALUE=\"$in{text_box}\">
> <BR>
> <I>Text Area:</I>
> <TEXTAREA NAME=\"text_area\" ROWS=\"2\"
COLS=\"50\">$in{text_area}</TEXTAREA>
> </FORM>
> <P>
> Text Box Input: $in{text_box}<P>
> Text Area Input: $in{text_area}<P>
> Button Input: $in{forward}<P>
> </HTML>";
>
I see you're reverting back to extolling the virtues of perl 4. Lay off the
scanning the server logs and take some time to read about here documents.
Matt
| |
| Purl Gurl 2004-06-29, 8:56 pm |
| Anthos wrote:
> Purl Gurl wrote:
(snipped)
> I already did this for both, but it didn't worked;
Your question was about how to use a graphic for a form button.
My suggestion is you add print statements for each
major step of your script. Print your variable name
and print your variable value. Check to discover if
all values are as expected.
You need to pull the name / value pairs for your
submit button. Those will be in your form parser
hash. Make sure all your form variables are
present in your script for use.
Change to a plaintext format,
print "Content-type: text/plain\n\n";
Now add print statements,
$start=$FORM{"from"};
print "START = $start\n";
$increment=$FORM{"max"};
print "INCREMENT 1 = $increment\n";
$increment=$maxPages if (!($increment));
print "INCREMENT 2 = $increment\n";
Continue on through your script. Return a plaintext
print, then examine your variable values.
Purl Gurl
| |
| Anthos 2004-06-30, 3:57 pm |
| "Purl Gurl" <purlgurl@purlgurl.net> ha scritto nel messaggio
news:40E20D4A.FF1777EB@purlgurl.net...
<snip>
> Change to a plaintext format,
>
> print "Content-type: text/plain\n\n";
>
> Now add print statements,
>
> $start=$FORM{"from"};
>
> print "START = $start\n";
>
> $increment=$FORM{"max"};
>
> print "INCREMENT 1 = $increment\n";
>
> $increment=$maxPages if (!($increment));
>
> print "INCREMENT 2 = $increment\n";
>
>
> Continue on through your script. Return a plaintext
> print, then examine your variable values.
Ok, ty.
| |
| greger 2004-07-01, 3:55 am |
|
"Anthos" <via@spam.sp> wrote in message
news:RfhEc.393933$hc5.17013280@news3.tin.it...
> Hello, I downloaded a search script (open source), that seems the most
> simple and customizable among all I scrutined so far (indeed, there are
few
> choices), and I was able to modify the most of easier features in order to
> match my requirements, though since two days so far I'm stuck with the
> following commands:
>
> print "$display\n";
> }
> print "<center><form name=\"more\" action=\"$thisScript\">\n";
> if ($start>0) {print "<input type=\"submit\" name=\"back\"
> value=\" \">\n";}
> if ($end<@results) {print "<input type=\"submit\" name=\"forward\"
> value=\" \">\n";}
> print "<input type=\"hidden\" name=\"from\" value=\"$start\">\n";
> print "<input type=\"hidden\" name=\"log\" value=\"false\">\n";
> foreach $key (keys %FORM)
> {
> $val=$FORM{$key};
> next if (($key eq "back") or ($key eq "forward") or ($key eq "from"));
> print "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n";
> }
> print "<\/form><\/center>\n";
> }
> else {print "<center><img border='0'
> src='http://www.yoursite.com/images/msg_errorsearch.gif'><br>\n"}
>
> I wish to substitute the pesky form buttons with images or text either,
but
> I wasn't able to. How to? Time ago I heard casually about kinda
javascripts
> that do so that a submit button can be triggered by a text or image link,
> but I wasn't able to find any (problem with thinking any decent keywords
for
> google). Can anyone help me please?
> If that suite of commands doesn't lead to any solutions of modify, in the
> case it depends from some other rows on the script, I can also privately
> send the script to have a complete view of it.
>
>
is is also possible to use
<a href=your_perl_script?action=forward>[NEXT]</a>
<a href=your_perl_script?action=backward>[PREV]</a>
aand in your scirpt
my $action = CGI->param('action');
if ($action eq "forward" ){
go forward
}elsif($qction eq "backward"){
go backward...
}
hope this helps
/G
--
www.gh-webinteractive.com
|
|
|
|
|