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 a search where results call a perl subroutine

Status
Not open for further replies.

webdevelopernj

Programmer
Jul 1, 2002
9
US
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(&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;;
exit 0;
}

The code I need to have:

sub createEditButtons() {
for($g=0;$g<$editFlagSet;$g++) { print &quot;EDIT&quot;.$g.&quot;<br>&quot;;
$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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top