Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create HTML buttons on the fly with cgi.pm

Status
Not open for further replies.

webdevelopernj

Programmer
Jul 1, 2002
9
US
I am trying to dynamically create html buttons on the fly. Normally when I call a function after a button is pressed I used code like this:
$query = &restore_parameters($query) if $query->param('action') eq 'EDIT';

The function call above to restore_parameters is a well recognized functions, as it is available over many websites.

my problem is that I want to dynamically create a function call after a search routine is finished.
I successfully created a static call to the restore function by:
$query = &restore_parameters($query,0) if $query->param('action') eq 'EDIT0';
$query = &restore_parameters($query,1) if $query->param('action') eq 'EDIT1';
$query = &restore_parameters($query,2) if $query->param('action') eq 'EDIT2';

I figure I could create this dynamically with $x and a for loop, however the cgi program can't find the function once it is wrapped in the for loop, the for loop works i tested print statement in it, however I believe by being wrapped in conditions it doesn't have the constant exposure on a triggered event, I don't know if i making much sense here but please send me any info you may have.

Here is the for loop I was attempting to work with:
for($g=0;$g<$editFlagSet;$g++) { print $g.&quot;<br>&quot;;
$query = &restore_parameters($query,$g) if $query->param('action')eq 'EDIT'.$g;
}
Not sure you need this, but here is search function, it sets the $editFlagSet variable **************************************************
sub printDBResults {
open(DATAFILE,&quot;searchresults&quot;);
while(<DATAFILE>){
s/%([\dA-Fa-f][\dA-Fa-f])/pack(&quot;c&quot;,hex($1))/eg;
@temp = split /\n/;
foreach $tem (@temp) {
@seperate = split /:/;
#foreach $sep (@seperate) {
if ($seperate[0]){
$defaultname = $seperate[0];
$addToDefaultname = $defaultname . '_understood.txt';
print &quot; &quot;;
print $query->textfield('savefile'.$tempNum,$addToDefaultname,'17'),&quot;&nb
sp; &quot;;
print $query->submit('action','EDIT'.$editNum),&quot;<br>&quot;;
$editFlagSet++;
$tempNum++;
$editNum++;
}
}
}
close(DATAFILE);
print &quot;<br><br><a href=javascript:goBack()>New Search</a><br>&quot;;
#createEditButtons();
exit 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top