udsrem
12-01-2002, 10:38 PM
I was wondering if someone could help me with this program.
This program should work, but for some reason the hidden field dose not change when the programs runs. The program is listed below.
#!/usr/bin/perl
use CGI qw(-nosticky :all );
use CGI::Carp 'fatalsToBrowser';
$query = new CGI;
print $query->header;
print $query->start_html(-title=>'Blank Page',-style=>{'rel'=>'stylesheet','type'=>'text/css', 'src'=>'somekind.css'}, -class=>'content');
if ($query->param('help me') ) {
print $query->start_form({-method=>'post' ,-action=>'blank.cgi' ,-name=>'blank_form'});
print $query->hidden({-name=>'help me' ,-value=>'fdjlkjgsreughfjvkbsur/asadfdaseg'}); #hidden field when button pressed 1st time
print $query->start_table({-width=>'100%'});
print $query->Tr(td({-valign=>'bottom', -width=>'30%'},div({-class=>'page-title1'},Some kind of header!')),
td({-width=>'80%' ,-class=>'context'}),'Sorry, no help on this page',td({-align=>'right' ,-width=>'20%' },
image_button({-name=>'Help me' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))),
Tr(td({-class=>'table-line' ,-height=>'1' ,-colspan=>'7'}));
}
else {
print $query->start_form({-method=>'post' ,-action=>'blank.cgi' ,-name=>'blank_form'});
print $query->hidden({-name=>'help me' ,-value=>'fdjlkjgsreughfjvkbsurdtur'}); # hidden field on first run and when button pressed 2nd time
print $query->start_table({-width=>'100%'});
print $query->Tr(td({-valign=>'bottom', -width=>'30%'},div({-class=>'page-title1'},Some kind of header!')),
td({-width=>'80%' }),td({-align=>'right' ,-width=>'20%' },
image_button({-name=>'Help me' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))),
Tr(td({-class=>'table-line' ,-height=>'1' ,-colspan=>'7'}));
}
print $query->end_table;
print $query->end_form;
print end_html;
When the program runs it falls to the else statement and the form runs. When you click the image button the form changes and tells the user that there is no help on this page.
That works correctly, the problem is when you click the button again it should change back. It is not changing the hidden field it seems as if the hidden field is over looked. If I change the hidden fields name when the condition is true it works correctly. ('help me' to 'Help me')
I need to make it work with the hidden fields name staying the same at all times, just the value changes.
Can this be done and how.
Thanks
This program should work, but for some reason the hidden field dose not change when the programs runs. The program is listed below.
#!/usr/bin/perl
use CGI qw(-nosticky :all );
use CGI::Carp 'fatalsToBrowser';
$query = new CGI;
print $query->header;
print $query->start_html(-title=>'Blank Page',-style=>{'rel'=>'stylesheet','type'=>'text/css', 'src'=>'somekind.css'}, -class=>'content');
if ($query->param('help me') ) {
print $query->start_form({-method=>'post' ,-action=>'blank.cgi' ,-name=>'blank_form'});
print $query->hidden({-name=>'help me' ,-value=>'fdjlkjgsreughfjvkbsur/asadfdaseg'}); #hidden field when button pressed 1st time
print $query->start_table({-width=>'100%'});
print $query->Tr(td({-valign=>'bottom', -width=>'30%'},div({-class=>'page-title1'},Some kind of header!')),
td({-width=>'80%' ,-class=>'context'}),'Sorry, no help on this page',td({-align=>'right' ,-width=>'20%' },
image_button({-name=>'Help me' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))),
Tr(td({-class=>'table-line' ,-height=>'1' ,-colspan=>'7'}));
}
else {
print $query->start_form({-method=>'post' ,-action=>'blank.cgi' ,-name=>'blank_form'});
print $query->hidden({-name=>'help me' ,-value=>'fdjlkjgsreughfjvkbsurdtur'}); # hidden field on first run and when button pressed 2nd time
print $query->start_table({-width=>'100%'});
print $query->Tr(td({-valign=>'bottom', -width=>'30%'},div({-class=>'page-title1'},Some kind of header!')),
td({-width=>'80%' }),td({-align=>'right' ,-width=>'20%' },
image_button({-name=>'Help me' ,-src=>'/images/context_help.gif' ,-align=>'absmiddle' ,-height=>'17' ,-alt=>'Help' ,-border=>'0' ,class=>'button-context' ,-width=>'17'}))),
Tr(td({-class=>'table-line' ,-height=>'1' ,-colspan=>'7'}));
}
print $query->end_table;
print $query->end_form;
print end_html;
When the program runs it falls to the else statement and the form runs. When you click the image button the form changes and tells the user that there is no help on this page.
That works correctly, the problem is when you click the button again it should change back. It is not changing the hidden field it seems as if the hidden field is over looked. If I change the hidden fields name when the condition is true it works correctly. ('help me' to 'Help me')
I need to make it work with the hidden fields name staying the same at all times, just the value changes.
Can this be done and how.
Thanks