Click to See Complete Forum and Search --> : Clickable Image Button


udsrem
11-24-2002, 12:53 AM
I know this code should work but can not figure out why. Get error that something is wrong with the IF statement, I've looked a different programs and the codding looks alright. Could Someone look at this code and show what it would take to get it to work. Thanks

When the image button is pressed it should reload the screen to add a help screen and when the button is pressed again it should reload it again but that time it removes it.

The code:

#!/usr/bin/perl -w

use CGI ':standard';
my $query = new CGI;
print $query->header;
print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>";
print $query->start_html(-title=>'Blank Page',-author=>'##########', -expires=>'now',
-style=>{'rel'=>'stylesheet','type'=>'text/css', 'src'=>'webley.css'}, -class=>'content',
-onLoad=>"if(######){######('#######')}");
print $query->start_form({-method=>'post' ,-action=>'blank.cgi' ,name=>'help'});
print $query->table({-width=>'100%'},
print $query->Tr(td({-valign=>'bottom', -align=>'left' ,width=>'50%'},div({-class=>'page-title'},'### ##### ########')),

if ($query->param('Help.x')) {
print td({-align=>'center' ,-width=>'50%' ,-colspan=>'3',-class=>'page-title'}),'Did it Work',td({-align=>'center' ,-width=>'50%' ,-colspan=>'7'});
print image_button({-name=>'Help_content' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))
}
else {
print td({-align=>'center' ,-width=>'50%' ,-colspan=>'3' }),td({-align=>'center' ,-width=>'50%' ,-colspan=>'7'});
print image_button({-name=>'Help' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))
},
);
print "</FORM>";
print "<hr />";
print $query->end_html;

jeffmott
11-24-2002, 08:37 AM
The statement prior to the if statement is ended with a comma rather than a semi-colon. This same error is made on other lines as well. You also have some open parenthese that are not closed.

use CGI::Carp 'fatalsToBrowser';

Add this to your script to view error messages instead of an Internal Server Error page.

udsrem
11-24-2002, 11:57 AM
Thanks Jeff, the code did help also changing come of the , to ; also help :)

udsrem
11-25-2002, 05:03 PM
Actually after making the changes to the code worked but only one-way. You would click the image and the text would show up, but when you clicked the image again it would not remove it. That's actually what I'm looking for it to do. The code is up a couple of reply's. Below is what I like it to do.

Example:

Hello to my world! (image Here)

Click the image, page reloads and now it says,

Hello to my world! Time is ##:##:## (image Here)

That works with no problems, the problems is when you

Click the image again, page should reloads and it returns to what it said at first.

Hello to my world! (image Here)

I know it deals with a param using the Delete_all() function, I just not sure how to code that in for it to work.

Any help would be helpful, and thanks again. :)

jeffmott
11-25-2002, 06:47 PM
Here's a basic example script that does what you're looking for.

#!/usr/local/bin/perl -Tw

use strict;
use CGI 'param';

my $help = param('help');

print q`Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Testing</title>
</head>

<body>
`;

if ( $help eq 'show' ) {
print q`<div>--HELP MENU HERE--</div><div><a href="test.pl">Hide Help</a></div>`;
}
else {
print q`<div><a href="test.pl?help=show">Show Help</a></div>`;
}

print q`
</body>

</html>`;

Use this example to write an implementation in your own code.

udsrem
11-25-2002, 09:21 PM
Thanks, But can this be done in a form using tables and image buttons and the program called hep.cgi .

form:
method=post
name=help
action=help.cgi

image:
name=Help
scr=/images/help.gif


the only reason I ask this is the program I'm currently writting only uses image buttons.

The program may go live and the other programmers that I work with only like to use Images, I've tried to talk them into links, but talking is like spitting in the wind, also I'm the last in line no weight yet.

jeffmott
11-25-2002, 09:40 PM
only uses image buttons

So change the text 'show help' and 'hide help' to image tags.

udsrem
11-25-2002, 09:48 PM
Thanks, have a good one :)