webdevelopernj
Programmer
I currently have a search implemented where the results are returned in a textfield with an adjacent 'EDIT' button that calls restore_parameters when click.
I've modified the code to handle three results by providing an EDIT1, EDIT2, and EDIT3 buttons that each related to TEXTFIELD1,TEXTFIELD2,TEXTFIELD3 respectively.
However I want to be able to generate these buttons and fields dynamically where they can successfully restore there respective files.
My functional working code look like:
print $query->start_form( -name=>'startform', -action=>'fixSearch.cgi');
$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';
*****************EDIT buttons are created here************
sub printDBResults {
open(DATAFILE,"searchresults"
while(<DATAFILE>){
s/%([\dA-Fa-f][\dA-Fa-f])/pack("c",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 " ";
print $query->textfield('savefile'.$tempNum,$addToDefaultname,'17'),"&nb
sp; ";
print $query->submit('action','EDIT'.$editNum),"<br>";
$editFlagSet++;
$tempNum++;
$editNum++;
}
}
}
close(DATAFILE);
print "<br><br><a href=javascript:goBack()>New Search</a><br>";
exit 0;
}
The code I need to have:
sub createEditButtons() {
for($g=0;$g<$editFlagSet;$g++) { print "EDIT".$g."<br>";
$query = &restore_parameters($query,$g) if $query->param('action') eq 'EDIT'.$g;
}
}
*************EDIT BUTTONS are created the same as above - however before I exit I call createEditButtons.
I've modified the code to handle three results by providing an EDIT1, EDIT2, and EDIT3 buttons that each related to TEXTFIELD1,TEXTFIELD2,TEXTFIELD3 respectively.
However I want to be able to generate these buttons and fields dynamically where they can successfully restore there respective files.
My functional working code look like:
print $query->start_form( -name=>'startform', -action=>'fixSearch.cgi');
$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';
*****************EDIT buttons are created here************
sub printDBResults {
open(DATAFILE,"searchresults"
while(<DATAFILE>){
s/%([\dA-Fa-f][\dA-Fa-f])/pack("c",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 " ";
print $query->textfield('savefile'.$tempNum,$addToDefaultname,'17'),"&nb
sp; ";
print $query->submit('action','EDIT'.$editNum),"<br>";
$editFlagSet++;
$tempNum++;
$editNum++;
}
}
}
close(DATAFILE);
print "<br><br><a href=javascript:goBack()>New Search</a><br>";
exit 0;
}
The code I need to have:
sub createEditButtons() {
for($g=0;$g<$editFlagSet;$g++) { print "EDIT".$g."<br>";
$query = &restore_parameters($query,$g) if $query->param('action') eq 'EDIT'.$g;
}
}
*************EDIT BUTTONS are created the same as above - however before I exit I call createEditButtons.