udsrem
11-21-2002, 05:32 PM
Trying to create a page that when you click a icon it reload the page but adds code to the page, then click it again and it removes the code. Example Click help icon on page, reloads and help screen is inserted, press help icon again and it disappears
Zach Elfers
11-22-2002, 12:23 PM
You could do this with JavaScript. Maybe like this.
<a href="www.site.com" onClick="javascript:refresh();">
<div style="display:none;" onReload="docment.style.display == 'block';">
Info
</div>
On don't know if onReload is a real event handler, but onLoad is.:)
udsrem
11-22-2002, 12:32 PM
Thanks, that might work. But I'm really looking for an answer that dose it in perl and cgi
Zach Elfers
11-22-2002, 12:38 PM
I don't know those languages yet. Sorry!:)
udsrem
11-22-2002, 12:45 PM
That's ok, Maybe someone else will be help. And thanks again.
jeffmott
11-22-2002, 03:30 PM
#!/usr/local/bin/perl -Tw
use strict;
use CGI ':standard';
print "Content-Type: text/html\n\n";
print q`
<!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>Guestbook</title>
</head>
<body>
`;
if ( param('help') eq 'show' ) {
print '-- HELP SCREEN HERE --<br><a href="script.pl">hide help screen</a>';
}
else {
print '<a href="script.pl?help=show">show help screen</a>';
}
print q`
</body>
</html>
`;
udsrem
11-22-2002, 05:24 PM
The script worked, how could you convert it to work with a form and an image button. like this example -
#!/usr/bin/perl
use CGI qw(:standard :netscape);
print header;
print start_html(-title=>'Blank Page',
-stlye=>'rel'=>'stylesheet','type'=>'text/css', 'src'=>'###.css'}
, -class=>'content',
-onLoad=>"if(#######){########('########')}");
print start_form({-method=>'post' ,-action=>'blank.cgi' ,
name=>'help'});
print table({-width=>'100%'},Tr(td({-valign=>'bottom', -align=>'left' ,width=>'50%'},div({-class=>'page-title'},'#### ### ######!')), td({-align=>'center' ,-width=>'50%' ,-colspan=>'3'}),td({-align=>'center' ,-width=>'50%' ,-colspan=>'7'}), image_button({-name=>'Help' ,-src=>'/images/help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))
);
print end_form;
print hr;
to this
print header;
print start_html(-title=>'Blank Page',
-stlye=>'rel'=>'stylesheet','type'=>'text/css', 'src'=>'###.css'}
, -class=>'content',
-onLoad=>"if(######){#######('########')}");
print start_form({-method=>'post' ,-action=>'blank.cgi' ,
name=>'help'});
print table({-width=>'100%'}, Tr(td({-valign=>'bottom', -align=>'left' ,width=>'50%'},div({-class=>'page-title'},#### ### ######!')), td({-align=>'center' ,-width=>'50%' ,-colspan=>'3'}),'TEXT IS PLACED HERE',td({-align=>'center' ,-width=>'50%' ,-colspan=>'7'}), image_button({-name=>'Help' ,-src=>'/images/help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))
);
print end_form;
print hr;
And yes I do know some perl and cgi, i just don' know how to code that kind of condition in
jeffmott
11-22-2002, 06:56 PM
If you want to do it with a form then just insert it as a hidden field.
<input type="hidden" name="help" value="show">
The omit this field if param('help') eq 'show' so in that case when the form is submitted there will be no help value passed.
udsrem
11-22-2002, 07:01 PM
Thanks, Ill give it a try:)