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!

Search results that can call 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.
 
I'm sorry, but I don't understand what your problem is. If the subroutine that you posted is what you need to have then use it. How is it not working?

jaa
 
The actual subroutine gets called and the for loop is ran (i tested it with print statements) however, the actual call to &quot;restore_parameters&quot; doesn't get called, I believed this has to be exposed globally ( not enclosed in a subroutine) so that cgi has constant access to the call.

So my question is how can i expose the statement:
$query = &restore_parameters($query,$g) if $query->param('action') eq 'EDIT'.$g;

while generating an array of edit buttons with unique names
 
I don't think that its a scope problem. If all subroutines are defined in the same script then that probably isn't your problem.

The most glaring error that I see in your posted code is that the
Code:
printDBResults
subroutine exits rather than returns. This is usually a no-no unless the subroutine is doing signal catching or error handling. This might be the cause of your problem. If not post back, perhaps with the
Code:
restore_parameters
sub if its not to big.

jaa
 
The reason i was exiting was b/c after I type in the search string in the search box, the search box would display again under the results, this is ok, however, the subroutine restore_parameters still does not get called.

here is the entire code:
#!/usr/add-on/exptools/bin/perl

use CGI;
$query = new CGI;

$JSCRIPT=<<EOF;

function setFocus() {
if (document.startform.searchval) {
document.startform.searchval.focus();
}
}

function goBack() {
window.history.back();
}

function filterColons(str) {
re = /:/g;
//remove &quot;:&quot;
return str.replace(re, &quot;-&quot;);
}

function setnameField(theCheckBox) {
document.all('savefile').value = document.all('searchChoice').value;
alert(document.all('searchChoice').value);
alert(document.all('savefile').value);
}


EOF
;

$ENV{'PATH'} .= &quot;:/usr/add-on/exptools/lib/unity/bin&quot;;

$box_checked = 0;
$x = 0;
$t = 0;
$tempNum = 0;
$editNum = 0;
$editFlagSet = 0;

print $query->header;
print $query->start_html( -title=>'Fill out and save config sheet', -BGCOLOR=>'#ffffff', -script=>$JSCRIPT, -onLoad=>'setFocus()', -vlink=>'ff0000', -link=>'0000ff');

print $query->start_form( -name=>'startform', -action=>'fixWithArray.cgi');

$mailprog =&quot;/opt/mail/bin/post&quot;;

&read_inpugt($query) if $query->param('action') eq 'SAVE';
&sure_save($query) if $query->param('action') eq 'YES';
&not_sure($query) if $query->param('action') eq 'NO';

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;
}

}
#$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';

&display_results($query) if $query->param('action') eq 'SEARCH';

# here, we pass no arguments nor have values passed back
&show_form() if ($ENV{QUERY_STRING} eq '');
log_it($firstname,$lastname,$email,$labmr);
exit();


sub display_results {
$valueused = $query->param('searchval');
print &quot;<b><font color=0000ff>The value searched for was $valueused</font></b><br><br>&quot;;
$start_search = `uselect -q from understood where labmr req $valueused > searchresults 2>searchresults`;
print $start_search;
printDBResults();
$t = 1;
}

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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;;
print $query->textfield('savefile'.$tempNum,$addToDefaultname,'17'),&quot;&nbsp;&nbsp;&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;
return;
}

sub submitToDatabase {
$one = $query->param('labmr');
$two = $query->param('meetdate');
$three = $query->param('planner');
$four = $query->param('labnum');
$five = $query->param('msc');
$six = $query->param('technology');
$seven = $query->param('understoodcellnum');
$eight = $query->param('celltype');
$nine = $query->param('typeother');
$ten = $query->param('comment1');
$eleven = $query->param('asked1');
$twelve = $query->param('response1');
$thirteen = $query->param('questionner1');
$fourteen = $query->param('comment2');
$fifteen = $query->param('asked2');
$sixteen = $query->param('response2');
$seventeen = $query->param('questionner2');
$eightteen = $query->param('comment3');
$nineteen = $query->param('asked3');
$twenty = $query->param('response3');
$twentyone = $query->param('questionner3');
$twentytwo = $query->param('comment4');
$twentythree = $query->param('asked4');
$twentyfour = $query->param('response4');
$twentyfive = $query->param('questionner4');
$twentysix = $query->param('comment5');
$twentyseven = $query->param('asked5');
$twentyeight = $query->param('response5');
$twentynine = $query->param('questionner5');
$thirty = $query->param('comment6');
$thirtyone = $query->param('asked6');
$thirtytwo = $query->param('response6');
$thirtythree = $query->param('questionner6');
$thirtyfour = $query->param('mscrep');
$thirtyfive = $query->param('msccomment');
$thirtysix = $query->param('fiveerep');
$thirtyseven = $query->param('fiveecomment');
$thirtyeight = $query->param('cellrep');
$thirtynine = $query->param('cellcomment');
$forty = $query->param('netrep');
$fortyone = $query->param('netcomment');
$fortytwo = $query->param('ecprep');
$fortythree = $query->param('ecpcomment');
$fortyfour = $query->param('rfrep');
$fortyfive = $query->param('rfcomment');
$fortysix = $query->param('platformrep');
$fortyseven = $query->param('platformcomment');
$fortyeight = $query->param('powerrep');
$fortynine = $query->param('powercomment');
$fifty = $query->param('toolsrep');
$fiftyone = $query->param('toolscomment');
$fiftytwo = $query->param('labplannerrep');
$fiftythree = $query->param('labplannercomment');
$fiftyfour = $query->param('mobilesrep');
$fiftyfive = $query->param('mobilescomment');
$fiftysix = $query->param('comments');

##################################################
# Concat variables into one string
#
$concat = $one.':'.$two.':'.$three.':'.$four.':'.$five.':'.$six.':'.$seven.':'.$eight.':'.$nine.':'.$ten;

$concat .= ':'.$eleven.':'.$twelve.':'.$thirteen.':'.$fourteen.':'.$fifteen.':'.$sixteen.':'.$seventeen.':'.$eightteen.':'.$nineteen.':'.$twenty.':'.$twentyone.':'.$twentytwo.':'.$twentythree.':'.$twentyfour.':'.$twentyfive.':'.$twentysix.':'.$twentyseven.':'.$twentyeight.':'.$twentynine.':'.$thirty;

$concat .= ':'.$thirtyone.':'.$thirtytwo.':'.$thirtythree.':'.$thirtyfour.':'.$thirtyfive.':'.$thirtysix.':'.$thirtyseven.':'.$thirtyeight.':'.$thirtynine.':'.$forty;

$concat .= ':'.$fortyone.':'.$fortytwo.':'.$fortythree.':'.$fortyfour.':'.$fortyfive.':'.$fortysix.':'.$fortyseven.':'.$fortyeight.':'.$fortynine.':'.$fifty;

$concat .= ':'.$fiftyone.':'.$fiftytwo.':'.$fiftythree.':'.$fiftyfour.':'.$fiftyfive.':'.$fiftysix.&quot; \n&quot;;
##################################################

$tmpfile = &quot;tmp_understood.&quot; . $query->param('labmr');
$param_labmr = $query->param('labmr');
open(TEMPFILE,&quot;>nonhtml/$tmpfile&quot;);

#remove all newlines so unity file does not represent as a new record.
#append one newline character back so file is a valid unity file.
$tt = (join('',split(/\n/,$concat)));
$tt = $tt. &quot;\n&quot;;

print TEMPFILE $tt;
close(TEMPFILE);
system &quot;chmod 777 nonhtml/$tmpfile&quot;;

$result = `udelete from understood where labmr leq $param_labmr`;
$result2 = `insert in understood from nonhtml/$tmpfile`;
print &quot;$result&quot;;
print &quot;$result2&quot;;

}

sub are_you_sure {
print &quot;<br><br><br><br><br><br><br><br><br>&quot;;

#this variable is used to see if the file already exists
$thefileName = $query->param('savefile');

#this array is used to make sure file name and labmr number match
@splitFileName = split('_',$thefileName);

if ($splitFileName[0] != $query->param('labmr')) {
print &quot;<strong><center><font size=5 color=ff0000>Error: Labmm # doesn't match file name!<br>Go back, using the browser Back button</font></center></strong>&quot;;
exit 0;
}

if (-e &quot;nonhtml/$thefileName&quot;) {
print &quot;<font size=5 color=000000><b><center><font color=ff0000>Warning! </font> This file already exist</center></b></font>&quot;;
} else {
print &quot;<font size=5 color=000000><b><center>This file doesn't exist... let's continue</center></b></font>&quot;;
}

print &quot;<font size=5 color='#ff0000'><center><b>Are you sure you want to SAVE</b><br><br>&quot;;
print $query->submit('action','YES');
print &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;;
print $query->submit('action','NO');
print &quot;<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>&quot;;
return $query;
}

sub sendMessage {

$docName = $query->param('labmr');
$thisMessage = &quot;This is an automated email, please do not reply to it.\n The understood document for Labmr: $docName has been updated.\n&quot;;
$thisMessage .= &quot;\nTo view the understood document goto:\n $thisMessage .= &quot;\nTo edit the understood document goto:\n

if (open(MAILFILE,&quot;>messages/thisfile&quot;)) {
print &quot;file opened&quot;;
}
print MAILFILE $thisMessage;
close(MAILFILE);

$Addrs = &quot;leom-ellis\@nwmail\.wh\.lucent\.com&quot;;
$fName = &quot;messages/thisfile&quot;;
$subject = &quot;Understood Sheet Available&quot;;
$mail = `cat $fName | $mailprog -s \&quot;$subject\&quot; $Addrs 2>null`;
print &quot;$mail&quot;;
}

sub sure_save {
local($query) = @_;
local($filename) = &clean_name($query->param('savefile'));
if (open(FILE,&quot;>$filename&quot;)) {
$query->save(FILE);
close FILE;
#****************************************************************
#****************************************************************
#
# Submit to Database here
# call submit function
submitToDatabase();
createFile_fromDB();
#
#****************************************************************
#****************************************************************
print &quot;<font color=000000><STRONG>File has been saved to $filename</STRONG></font>\n&quot;;
print &quot;<font color=000000><P>If you remember this name you can restore the document later.</font>\n&quot;;
print &quot;<br>&quot;;
print $query->a({-href=>' size=5 color=000000><br><center><b>View all Saved Understood Sheets</b></center></font><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><center><b>ELLIS Project</b><br><small><a href=' Home</a> | <a href=' East</a> | <a href=' West</a> | <a href=' Home</a> | <a href=' Home</a></center></font>&quot;);
} else {
print &quot;<font color=ff0000><STRONG>Error:</STRONG> couldn't write to file $filename: $!</font>&quot;;
}
$turned_on = $query->param('mail_value');

if ($turned_on eq 'on') {
sendMessage();
}
else {
print &quot;no mail sent&quot;;
}
exit 0;
}

sub not_sure{
$x =1;
}

sub save_parameters {
&are_you_sure($query);
}


sub restore_parameters {
$x++;
local($query,$someval) = @_;
print $someval,&quot;<br>&quot;;
if ($someval == 0) {
print &quot;Inside the if statement<br>&quot;;
$filename = &clean_name($query->param('savefile0'));
}
elsif ($someval == 1) {
$filename = &clean_name($query->param('savefile1'));
}
elsif ($someval == 2) {
$filename = &clean_name($query->param('savefile2'));
}
else {
print &quot;Variable is not in the defined scope&quot;;
}

if (open(FILE,$filename)) {
$query = new CGI(FILE);
# Throw out the old query, replace it with a new one
close FILE;
print &quot;<STRONG>The file $filename has been restored</STRONG>\n&quot;;
} else {
print &quot;<STRONG>Error:</STRONG> couldn't restore file $filename: $!\n&quot;;
}
return $query;
}

sub clean_name {
local($name) = @_;
#unless ($name=~/^[\w\._\-]+$/) {
# print &quot;<font color=ff0000><STRONG>$name has naughty characters or You forgot to name the file. Only &quot;;
# print &quot;alphanumerics are allowed. You can't use absolute names.</STRONG></font>&quot;;
# die &quot;Attempt to use naughty characters&quot;;
#}
return &quot;nonhtml/$name&quot;;
}

sub createFile_fromDB {
$input = $tmpfile;
open(SOMEFILE,&quot;nonhtml/$input&quot;);
open(DBTOHTML,&quot;>html/$input.html&quot;);
flock(DBTOHTML, 2) or die &quot;cannont lock $input: $!&quot;;
while(<SOMEFILE>) {
s/%([\dA-Fa-f][\dA-Fa-f])/pack(&quot;c&quot;,hex($1))/eg;
@seperate = split /:/;
@parseOut = split('\r',$seperate[55]);
$sep = '<h2>LEOM - Understood - Resaved</h2><form><table width=85% bgcolor=yellow border=2><tr><td colspan=2><b>LabMR </b>'.$seperate[0].'</td><td colspan=2><b>Initial meet date </b>'.$seperate[1].'</td></tr><tr><td colspan=2><b>LEOM Planner </b>'.$seperate[2].'</td><td><b>Lab # </b>'.$seperate[3].'</td><td><b>MSC # </b>'.$seperate[4].'</td></tr>';
$sep .= '<tr><td><b>Technology </b>'.$seperate[5].'</td><td><b>Cell # </b>'.$seperate[6].'</td><td><b>Cell Type </b>'.$seperate[7].'</td><td><b>If other, specify </b>'.$seperate[8].'</td></tr></table>';
$sep .= '<br><table width=85% border=3 bgcolor=yellow><th colspan=2>Further Clarification Needed From Requester</th><tr><td width=8%><b>Issue</b></td><td width=50%><b><center>Comments</center></b></td><td width=14%><b>Date Asked</b></td><td width=14%><b>Response Date</b></td><td width=14%><b>Questionner Sign-off</b></td></tr>';
$sep .= '<tr><td><b>1</b></td><td>'.$seperate[9].'</td><td>'.$seperate[10].'</td><td>'.$seperate[11].'</td><td>'.$seperate[12].'</td></tr><tr><td><b>2</b></td><td>'.$seperate[13].'</td>';
$sep .= '<td>'.$seperate[14].'</td><td>'.$seperate[15].'</td><td>'.$seperate[16].'</td></tr><tr><td><b>3</b></td><td>'.$seperate[17].'</td><td>'.$seperate[18].'</td><td>'.$seperate[19].'</td><td>'.$seperate[20].'</td></tr>';
$sep .= '<tr><td><b>4</b></td><td>'.$seperate[21].'</td><td>'.$seperate[22].'</td><td>'.$seperate[23].'</td><td>'.$seperate[24].'</td></tr><tr><td><b>5</b></td><td>'.$seperate[25].'</td><td>'.$seperate[26].'</td><td>'.$seperate[27].'</td><td>'.$seperate[28].'</td></tr>';
$sep .= '<tr><td><b>6</b></td><td>'.$seperate[29].'</td><td>'.$seperate[30].'</td><td>'.$seperate[31].'</td><td>'.$seperate[32].'</td></tr></table>';
$sep .= '<br><br><table width=80% border=3 bgcolor=ffff00><th colspan=3>Configuration valid and understood</th><tr><td width=10%><b>Team</b></td><td width=20%><b>Representative</b></td><td width=70%><b>Comments</b></td></tr><tr><td>MSC</td><td>'.$seperate[33].'</td><td>'.$seperate[34].'</td></tr>';
$sep .= '<tr><td>5E</td><td>'.$seperate[35].'</td><td>'.$seperate[36].'</td></tr><tr><td>Cell</td><td>'.$seperate[37].'</td><td>'.$seperate[38].'</td></tr><tr><td>Network</td><td>'.$seperate[39].'</td><td>'.$seperate[40].'</td></tr><tr><td>ECP/ODA</td><td>'.$seperate[41].'</td><td>'.$seperate[42].'</td></tr><tr><td>RF</td><td>'.$seperate[43].'</td><td>'.$seperate[44].'</td></tr>';
$sep .= '<tr><td>Platform</td><td>'.$seperate[45].'</td><td>'.$seperate[46].'</td></tr><tr><td>Power</td><td>'.$seperate[47].'</td><td>'.$seperate[48].'</td></tr><tr><td>Tools</td><td>'.$seperate[49].'</td><td>'.$seperate[50].'</td></tr><tr><td>Lab Planner</td><td>'.$seperate[51].'</td><td>'.$seperate[52].'</td></tr><tr><td>Mobiles</td><td>'.$seperate[53].'</td><td>'.$seperate[54].'</td></tr></table>';
$sep .= '<br><table bgcolor=ffff00 border=2 width=70%><th>Additional Comments</th><tr><td>';
foreach $item (@parseOut) {
$sep .= $item.'<br>';
}
$sep .= '</td></tr></table></form>';

###########################################
print DBTOHTML $sep;
###########################################
}

close(SOMEFILE);
close(DBTOHTML);
}



sub show_form {
if ($x == 0 ) {
if ($t == 1 ) {
print &quot;<br><br>&quot;;
}
print &quot;<center><h2><font color=0000ff>Understood Documents</font></h2><br><br>&quot;;
print &quot;<table align=center border=1 bgcolor=#666666>&quot;;

print &quot;<tr><td colspan=2><br><br><font color=ffffff><b>Enter LabMR</b>&nbsp;&quot;;
print &quot;&nbsp;&nbsp;&nbsp;&quot;,$query->textfield( -name=>'searchval'),&quot;</font>&nbsp;&quot;;
print $query->submit('action','SEARCH'),&quot;</td></tr>&quot;;
print &quot;<tr><td colspan=2>&nbsp;</td></tr>&quot;;
print &quot;</td></tr></table></center>&quot;;
}
if ($t == 1) {
print &quot;</font><br><br>$sep&quot;;
}
if ($x == 1) {
print &quot;<br>&quot;;
print &quot;<h2><font color=0000ff>LEOM - Request Template - Understood</font></h2>&quot;;
print &quot;<table bgcolor=white cellspacing=2 cellpadding=1 border=4><tr><td colspan=2>&quot;;
print &quot;<b>Labmr:</b> &quot;,$query->textfield( -name=>'labmr', -size=>'8'),&quot;</td><td colspan=2>&quot;;
print &quot;<b>Initial meeting date:</b> &quot;,$query->textfield( -name=>'meetdate'),&quot;</td></tr>&quot;;
print &quot;<tr><td colspan=2><b>LEOM Planner: </b>&quot;,$query->textfield( -name=>'planner', -size=>'16');
print &quot;</td><td><b>Lab #</b> &quot;,$query->textfield( -name=>'labnum', -size=>'10');
print &quot;</td><td><b>MSC #</b> &quot;,$query->textfield( -name=>'msc', -size=>'10');
print &quot;</td></tr>&quot;;
print &quot;<tr><td><b>Technology</b>&quot;,$query->textfield( -name=>'technology', -size=>'12'),&quot;</td>&quot;;
print &quot;<td><b>Cell #</b>&quot;,$query->textfield( -name=>'understoodcellnum', -size=>'6'),&quot;</td>&quot;;
print &quot;<td><b>Cell Type</b>&quot;,$query->textfield( -name=>'celltype', -size=>'12'),&quot;</td>&quot;;
print &quot;<td><b>If other, specify</b>&quot;,$query->textfield( -name=>'typeother', -size=>'12'),&quot;</td></tr></table>&quot;;
print &quot;<br><table width=85% border=3 bgcolor=white><th colspan=2>Further Clarification Needed From Requester</th>&quot;;
print &quot;<tr><td colspan=3><font color=ff0000>Please do not enter colons :)) in the form!! Thank you!</td></tr><tr><td width=8%><b>Issue</b></td><td width=50%><b><center>Comments</center></b></td><td width=14%><b>Date Asked</b></td><td width=14%><b>Response Date</b></td><td width=14%><b>Questionner Sign-off</b></td></tr>&quot;;
print &quot;<tr><td><b>1</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment1', -size=>'60', -onBlur=>'this.form.comment1.value=filterColons(this.form.comment1.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked1', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response1', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner1', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>2</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment2', -size=>'60', -onBlur=>'this.form.comment2.value=filterColons(this.form.comment2.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked2', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response2', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner2', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>3</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment3', -size=>'60', -onBlur=>'this.form.comment3.value=filterColons(this.form.comment3.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked3', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response3', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner3', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>4</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment4', -size=>'60', -onBlur=>'this.form.comment4.value=filterColons(this.form.comment4.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked4', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response4', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner4', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>5</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment5', -size=>'60', -onBlur=>'this.form.comment5.value=filterColons(this.form.comment5.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked5', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response5', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner5', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>6</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment6', -size=>'60', -onBlur=>'this.form.comment6.value=filterColons(this.form.comment6.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td>&quot;, $query->hidden( -name=>'hidden', -size=>'12'),&quot;</td></tr>&quot;;
print &quot;</table>&quot;;
print &quot;<br><hr><br><table width=85% border=3 bgcolor=ffffff><th colspan=3>Configuration valid and understood</th><tr><td width=10%><b>Team</b></td><td width=20%><b>Representative</b></td><td width=70%><b>Comments</b></td></tr>&quot;;

print &quot;<tr><td>MSC</td><td>&quot;, $query->textfield( -name=>'mscrep', -size=>'20'),&quot;</td>&quot;;

print &quot;<td>&quot;,$query->textfield( -name=>'msccomment', -size=>'70', -onBlur=>'this.form.msccomment.value=filterColons(this.form.msccomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>5E</td><td>&quot;,$query->textfield( -name=>'fiveerep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'fiveecomment', -size=>'70',-onBlur=>'this.form.fiveecomment.value=filterColons(this.form.fiveecomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Cell</td><td>&quot;,$query->textfield( -name=>'cellrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'cellcomment', -size=>'70',-onBlur=>'this.form.cellcomment.value=filterColons(this.form.cellcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Network</td><td>&quot;,$query->textfield( -name=>'netrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'netcomment', -size=>'70', -onBlur=>'this.form.netcomment.value=filterColons(this.form.netcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>ECP/ODA</td><td>&quot;,$query->textfield( -name=>'ecprep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'ecpcomment', -size=>'70',-onBlur=>'this.form.ecpcomment.value=filterColons(this.form.ecpcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>RF</td><td>&quot;,$query->textfield( -name=>'rfrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'rfcomment', -size=>'70', -onBlur=>'this.form.rfcomment.value=filterColons(this.form.rfcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Platform</td><td>&quot;,$query->textfield(-name=>'platformrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'platformcomment', -size=>'70', -onBlur=>'this.form.platformcomment.value=filterColons(this.form.platformcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Power</td><td>&quot;,$query->textfield(-name=>'powerrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'powercomment', -size=>'70', -onBlur=>'this.form.powercomment.value=filterColons(this.form.powercomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Tools</td><td>&quot;,$query->textfield(-name=>'toolsrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'toolscomment', -size=>'70', -onBlur=>'this.form.toolscomment.value=filterColons(this.form.toolscomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Lab Planner</td><td>&quot;,$query->textfield(-name=>'labplannerrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'labplannercomment', -size=>'70', -onBlur=>'this.form.labplannercomment.value=filterColons(this.form.labplannercomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Mobiles</td><td>&quot;,$query->textfield(-name=>'mobilesrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'mobilescomment', -size=>'70', -onBlur=>'this.form.mobilescomment.value=filterColons(this.form.mobilescomment.value)'),&quot;</td></tr></table></center>&quot;;
print &quot;<br><table border=2 bgcolor=ffffff><th>Additional Comments</th><tr><td>&quot;,$query->textarea(-name=>'comments', -cols=>'75', -rows=>'8', -onBlur=>'this.form.comments.value=filterColons(this.form.comments.value)'),&quot;</td></tr></table><br>&quot;;
#$temp = $query->param('labmr');
#$default_name = $temp . '_understood.txt';
print &quot;<center><table><tr><td>&quot;,$query->textfield(-name=>'savefile'),&quot;&nbsp;&nbsp;&quot;;
#print &quot;<center><table><tr><td>&quot;,$query->textfield('savefile',$default_name),&quot;&nbsp;&nbsp;&quot;;
print &quot;<font color=0000ff><br>If you have completed the form and wish<br> to notify the group, check \'
Send Mail\'<br>&quot;;
print $query->checkbox(-name=>'mail_value', -label=>'Send Mail'),&quot;&nbsp;&nbsp;&quot;,$query->submit('action','SAVE'),&quot;</font></td></tr></table></center><br>&quot;;
}
} # show_form

sub get_input {
$i=0;
foreach $pair (split(/\&/,$ENV{QUERY_STRING})) {
($name[$i],$value[$i])=split(/=/,$pair,2);
$i++;
} # foreach
return ($labmr);
} # get_input

sub log_it {
$logstring.=localtime(time) . &quot;\t&quot; . join(&quot;\t&quot;,@_);
open(LOG, &quot;>>/logs&quot;)||die &quot;Can't write log:$!\n&quot;;
print LOG &quot;$logstring\n&quot;;
close(LOG);
} # log_it

sub print_output {
@_ = %FORM;
($firstname,$lastname,$email,$labmr, $default_name)=@_;
print &quot;<br>&quot;;
} # print_output

sub read_input {
&get_input();
$x=0;
$x++;
local ($buffer, @pairs, $pair, $name, $value, %FORM);
# Read in text
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq &quot;POST&quot;) {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}

# Split information into name/value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack(&quot;C&quot;, hex($1))/eg;
$FORM{$name} = $value;
}
%FORM;
&save_parameters($query);
} # read_input

print $query->endform;
print $query->end_html;
 
The reason i was exiting was b/c after I type in the search string in the search box, the search box would display again under the results, this is ok, however, the subroutine restore_parameters still does not get called.

here is the entire code:
#!/usr/add-on/exptools/bin/perl

use CGI;
$query = new CGI;

$JSCRIPT=<<EOF;

function setFocus() {
if (document.startform.searchval) {
document.startform.searchval.focus();
}
}

function goBack() {
window.history.back();
}

function filterColons(str) {
re = /:/g;
//remove &quot;:&quot;
return str.replace(re, &quot;-&quot;);
}

function setnameField(theCheckBox) {
document.all('savefile').value = document.all('searchChoice').value;
alert(document.all('searchChoice').value);
alert(document.all('savefile').value);
}


EOF
;

$ENV{'PATH'} .= &quot;:/usr/add-on/exptools/lib/unity/bin&quot;;

$box_checked = 0;
$x = 0;
$t = 0;
$tempNum = 0;
$editNum = 0;
$editFlagSet = 0;

print $query->header;
print $query->start_html( -title=>'Fill out and save config sheet', -BGCOLOR=>'#ffffff', -script=>$JSCRIPT, -onLoad=>'setFocus()', -vlink=>'ff0000', -link=>'0000ff');

print $query->start_form( -name=>'startform', -action=>'fixWithArray.cgi');

$mailprog =&quot;/opt/mail/bin/post&quot;;

&read_inpugt($query) if $query->param('action') eq 'SAVE';
&sure_save($query) if $query->param('action') eq 'YES';
&not_sure($query) if $query->param('action') eq 'NO';

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;
}

}
#$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';

&display_results($query) if $query->param('action') eq 'SEARCH';

# here, we pass no arguments nor have values passed back
&show_form() if ($ENV{QUERY_STRING} eq '');
log_it($firstname,$lastname,$email,$labmr);
exit();


sub display_results {
$valueused = $query->param('searchval');
print &quot;<b><font color=0000ff>The value searched for was $valueused</font></b><br><br>&quot;;
$start_search = `uselect -q from understood where labmr req $valueused > searchresults 2>searchresults`;
print $start_search;
printDBResults();
$t = 1;
}

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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;;
print $query->textfield('savefile'.$tempNum,$addToDefaultname,'17'),&quot;&nbsp;&nbsp;&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;
return;
}

sub submitToDatabase {
$one = $query->param('labmr');
$two = $query->param('meetdate');
$three = $query->param('planner');
$four = $query->param('labnum');
$five = $query->param('msc');
$six = $query->param('technology');
$seven = $query->param('understoodcellnum');
$eight = $query->param('celltype');
$nine = $query->param('typeother');
$ten = $query->param('comment1');
$eleven = $query->param('asked1');
$twelve = $query->param('response1');
$thirteen = $query->param('questionner1');
$fourteen = $query->param('comment2');
$fifteen = $query->param('asked2');
$sixteen = $query->param('response2');
$seventeen = $query->param('questionner2');
$eightteen = $query->param('comment3');
$nineteen = $query->param('asked3');
$twenty = $query->param('response3');
$twentyone = $query->param('questionner3');
$twentytwo = $query->param('comment4');
$twentythree = $query->param('asked4');
$twentyfour = $query->param('response4');
$twentyfive = $query->param('questionner4');
$twentysix = $query->param('comment5');
$twentyseven = $query->param('asked5');
$twentyeight = $query->param('response5');
$twentynine = $query->param('questionner5');
$thirty = $query->param('comment6');
$thirtyone = $query->param('asked6');
$thirtytwo = $query->param('response6');
$thirtythree = $query->param('questionner6');
$thirtyfour = $query->param('mscrep');
$thirtyfive = $query->param('msccomment');
$thirtysix = $query->param('fiveerep');
$thirtyseven = $query->param('fiveecomment');
$thirtyeight = $query->param('cellrep');
$thirtynine = $query->param('cellcomment');
$forty = $query->param('netrep');
$fortyone = $query->param('netcomment');
$fortytwo = $query->param('ecprep');
$fortythree = $query->param('ecpcomment');
$fortyfour = $query->param('rfrep');
$fortyfive = $query->param('rfcomment');
$fortysix = $query->param('platformrep');
$fortyseven = $query->param('platformcomment');
$fortyeight = $query->param('powerrep');
$fortynine = $query->param('powercomment');
$fifty = $query->param('toolsrep');
$fiftyone = $query->param('toolscomment');
$fiftytwo = $query->param('labplannerrep');
$fiftythree = $query->param('labplannercomment');
$fiftyfour = $query->param('mobilesrep');
$fiftyfive = $query->param('mobilescomment');
$fiftysix = $query->param('comments');

##################################################
# Concat variables into one string
#
$concat = $one.':'.$two.':'.$three.':'.$four.':'.$five.':'.$six.':'.$seven.':'.$eight.':'.$nine.':'.$ten;

$concat .= ':'.$eleven.':'.$twelve.':'.$thirteen.':'.$fourteen.':'.$fifteen.':'.$sixteen.':'.$seventeen.':'.$eightteen.':'.$nineteen.':'.$twenty.':'.$twentyone.':'.$twentytwo.':'.$twentythree.':'.$twentyfour.':'.$twentyfive.':'.$twentysix.':'.$twentyseven.':'.$twentyeight.':'.$twentynine.':'.$thirty;

$concat .= ':'.$thirtyone.':'.$thirtytwo.':'.$thirtythree.':'.$thirtyfour.':'.$thirtyfive.':'.$thirtysix.':'.$thirtyseven.':'.$thirtyeight.':'.$thirtynine.':'.$forty;

$concat .= ':'.$fortyone.':'.$fortytwo.':'.$fortythree.':'.$fortyfour.':'.$fortyfive.':'.$fortysix.':'.$fortyseven.':'.$fortyeight.':'.$fortynine.':'.$fifty;

$concat .= ':'.$fiftyone.':'.$fiftytwo.':'.$fiftythree.':'.$fiftyfour.':'.$fiftyfive.':'.$fiftysix.&quot; \n&quot;;
##################################################

$tmpfile = &quot;tmp_understood.&quot; . $query->param('labmr');
$param_labmr = $query->param('labmr');
open(TEMPFILE,&quot;>nonhtml/$tmpfile&quot;);

#remove all newlines so unity file does not represent as a new record.
#append one newline character back so file is a valid unity file.
$tt = (join('',split(/\n/,$concat)));
$tt = $tt. &quot;\n&quot;;

print TEMPFILE $tt;
close(TEMPFILE);
system &quot;chmod 777 nonhtml/$tmpfile&quot;;

$result = `udelete from understood where labmr leq $param_labmr`;
$result2 = `insert in understood from nonhtml/$tmpfile`;
print &quot;$result&quot;;
print &quot;$result2&quot;;

}

sub are_you_sure {
print &quot;<br><br><br><br><br><br><br><br><br>&quot;;

#this variable is used to see if the file already exists
$thefileName = $query->param('savefile');

#this array is used to make sure file name and labmr number match
@splitFileName = split('_',$thefileName);

if ($splitFileName[0] != $query->param('labmr')) {
print &quot;<strong><center><font size=5 color=ff0000>Error: Labmm # doesn't match file name!<br>Go back, using the browser Back button</font></center></strong>&quot;;
exit 0;
}

if (-e &quot;nonhtml/$thefileName&quot;) {
print &quot;<font size=5 color=000000><b><center><font color=ff0000>Warning! </font> This file already exist</center></b></font>&quot;;
} else {
print &quot;<font size=5 color=000000><b><center>This file doesn't exist... let's continue</center></b></font>&quot;;
}

print &quot;<font size=5 color='#ff0000'><center><b>Are you sure you want to SAVE</b><br><br>&quot;;
print $query->submit('action','YES');
print &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;;
print $query->submit('action','NO');
print &quot;<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>&quot;;
return $query;
}

sub sendMessage {

$docName = $query->param('labmr');
$thisMessage = &quot;This is an automated email, please do not reply to it.\n The understood document for Labmr: $docName has been updated.\n&quot;;
$thisMessage .= &quot;\nTo view the understood document goto:\n $thisMessage .= &quot;\nTo edit the understood document goto:\n

if (open(MAILFILE,&quot;>messages/thisfile&quot;)) {
print &quot;file opened&quot;;
}
print MAILFILE $thisMessage;
close(MAILFILE);

$Addrs = &quot;leom-ellis\@nwmail\.wh\.lucent\.com&quot;;
$fName = &quot;messages/thisfile&quot;;
$subject = &quot;Understood Sheet Available&quot;;
$mail = `cat $fName | $mailprog -s \&quot;$subject\&quot; $Addrs 2>null`;
print &quot;$mail&quot;;
}

sub sure_save {
local($query) = @_;
local($filename) = &clean_name($query->param('savefile'));
if (open(FILE,&quot;>$filename&quot;)) {
$query->save(FILE);
close FILE;
#****************************************************************
#****************************************************************
#
# Submit to Database here
# call submit function
submitToDatabase();
createFile_fromDB();
#
#****************************************************************
#****************************************************************
print &quot;<font color=000000><STRONG>File has been saved to $filename</STRONG></font>\n&quot;;
print &quot;<font color=000000><P>If you remember this name you can restore the document later.</font>\n&quot;;
print &quot;<br>&quot;;
print $query->a({-href=>' size=5 color=000000><br><center><b>View all Saved Understood Sheets</b></center></font><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><center><b>ELLIS Project</b><br><small><a href=' Home</a> | <a href=' East</a> | <a href=' West</a> | <a href=' Home</a> | <a href=' Home</a></center></font>&quot;);
} else {
print &quot;<font color=ff0000><STRONG>Error:</STRONG> couldn't write to file $filename: $!</font>&quot;;
}
$turned_on = $query->param('mail_value');

if ($turned_on eq 'on') {
sendMessage();
}
else {
print &quot;no mail sent&quot;;
}
exit 0;
}

sub not_sure{
$x =1;
}

sub save_parameters {
&are_you_sure($query);
}


sub restore_parameters {
$x++;
local($query,$someval) = @_;
print $someval,&quot;<br>&quot;;
if ($someval == 0) {
print &quot;Inside the if statement<br>&quot;;
$filename = &clean_name($query->param('savefile0'));
}
elsif ($someval == 1) {
$filename = &clean_name($query->param('savefile1'));
}
elsif ($someval == 2) {
$filename = &clean_name($query->param('savefile2'));
}
else {
print &quot;Variable is not in the defined scope&quot;;
}

if (open(FILE,$filename)) {
$query = new CGI(FILE);
# Throw out the old query, replace it with a new one
close FILE;
print &quot;<STRONG>The file $filename has been restored</STRONG>\n&quot;;
} else {
print &quot;<STRONG>Error:</STRONG> couldn't restore file $filename: $!\n&quot;;
}
return $query;
}

sub clean_name {
local($name) = @_;
#unless ($name=~/^[\w\._\-]+$/) {
# print &quot;<font color=ff0000><STRONG>$name has naughty characters or You forgot to name the file. Only &quot;;
# print &quot;alphanumerics are allowed. You can't use absolute names.</STRONG></font>&quot;;
# die &quot;Attempt to use naughty characters&quot;;
#}
return &quot;nonhtml/$name&quot;;
}

sub createFile_fromDB {
$input = $tmpfile;
open(SOMEFILE,&quot;nonhtml/$input&quot;);
open(DBTOHTML,&quot;>html/$input.html&quot;);
flock(DBTOHTML, 2) or die &quot;cannont lock $input: $!&quot;;
while(<SOMEFILE>) {
s/%([\dA-Fa-f][\dA-Fa-f])/pack(&quot;c&quot;,hex($1))/eg;
@seperate = split /:/;
@parseOut = split('\r',$seperate[55]);
$sep = '<h2>LEOM - Understood - Resaved</h2><form><table width=85% bgcolor=yellow border=2><tr><td colspan=2><b>LabMR </b>'.$seperate[0].'</td><td colspan=2><b>Initial meet date </b>'.$seperate[1].'</td></tr><tr><td colspan=2><b>LEOM Planner </b>'.$seperate[2].'</td><td><b>Lab # </b>'.$seperate[3].'</td><td><b>MSC # </b>'.$seperate[4].'</td></tr>';
$sep .= '<tr><td><b>Technology </b>'.$seperate[5].'</td><td><b>Cell # </b>'.$seperate[6].'</td><td><b>Cell Type </b>'.$seperate[7].'</td><td><b>If other, specify </b>'.$seperate[8].'</td></tr></table>';
$sep .= '<br><table width=85% border=3 bgcolor=yellow><th colspan=2>Further Clarification Needed From Requester</th><tr><td width=8%><b>Issue</b></td><td width=50%><b><center>Comments</center></b></td><td width=14%><b>Date Asked</b></td><td width=14%><b>Response Date</b></td><td width=14%><b>Questionner Sign-off</b></td></tr>';
$sep .= '<tr><td><b>1</b></td><td>'.$seperate[9].'</td><td>'.$seperate[10].'</td><td>'.$seperate[11].'</td><td>'.$seperate[12].'</td></tr><tr><td><b>2</b></td><td>'.$seperate[13].'</td>';
$sep .= '<td>'.$seperate[14].'</td><td>'.$seperate[15].'</td><td>'.$seperate[16].'</td></tr><tr><td><b>3</b></td><td>'.$seperate[17].'</td><td>'.$seperate[18].'</td><td>'.$seperate[19].'</td><td>'.$seperate[20].'</td></tr>';
$sep .= '<tr><td><b>4</b></td><td>'.$seperate[21].'</td><td>'.$seperate[22].'</td><td>'.$seperate[23].'</td><td>'.$seperate[24].'</td></tr><tr><td><b>5</b></td><td>'.$seperate[25].'</td><td>'.$seperate[26].'</td><td>'.$seperate[27].'</td><td>'.$seperate[28].'</td></tr>';
$sep .= '<tr><td><b>6</b></td><td>'.$seperate[29].'</td><td>'.$seperate[30].'</td><td>'.$seperate[31].'</td><td>'.$seperate[32].'</td></tr></table>';
$sep .= '<br><br><table width=80% border=3 bgcolor=ffff00><th colspan=3>Configuration valid and understood</th><tr><td width=10%><b>Team</b></td><td width=20%><b>Representative</b></td><td width=70%><b>Comments</b></td></tr><tr><td>MSC</td><td>'.$seperate[33].'</td><td>'.$seperate[34].'</td></tr>';
$sep .= '<tr><td>5E</td><td>'.$seperate[35].'</td><td>'.$seperate[36].'</td></tr><tr><td>Cell</td><td>'.$seperate[37].'</td><td>'.$seperate[38].'</td></tr><tr><td>Network</td><td>'.$seperate[39].'</td><td>'.$seperate[40].'</td></tr><tr><td>ECP/ODA</td><td>'.$seperate[41].'</td><td>'.$seperate[42].'</td></tr><tr><td>RF</td><td>'.$seperate[43].'</td><td>'.$seperate[44].'</td></tr>';
$sep .= '<tr><td>Platform</td><td>'.$seperate[45].'</td><td>'.$seperate[46].'</td></tr><tr><td>Power</td><td>'.$seperate[47].'</td><td>'.$seperate[48].'</td></tr><tr><td>Tools</td><td>'.$seperate[49].'</td><td>'.$seperate[50].'</td></tr><tr><td>Lab Planner</td><td>'.$seperate[51].'</td><td>'.$seperate[52].'</td></tr><tr><td>Mobiles</td><td>'.$seperate[53].'</td><td>'.$seperate[54].'</td></tr></table>';
$sep .= '<br><table bgcolor=ffff00 border=2 width=70%><th>Additional Comments</th><tr><td>';
foreach $item (@parseOut) {
$sep .= $item.'<br>';
}
$sep .= '</td></tr></table></form>';

###########################################
print DBTOHTML $sep;
###########################################
}

close(SOMEFILE);
close(DBTOHTML);
}



sub show_form {
if ($x == 0 ) {
if ($t == 1 ) {
print &quot;<br><br>&quot;;
}
print &quot;<center><h2><font color=0000ff>Understood Documents</font></h2><br><br>&quot;;
print &quot;<table align=center border=1 bgcolor=#666666>&quot;;

print &quot;<tr><td colspan=2><br><br><font color=ffffff><b>Enter LabMR</b>&nbsp;&quot;;
print &quot;&nbsp;&nbsp;&nbsp;&quot;,$query->textfield( -name=>'searchval'),&quot;</font>&nbsp;&quot;;
print $query->submit('action','SEARCH'),&quot;</td></tr>&quot;;
print &quot;<tr><td colspan=2>&nbsp;</td></tr>&quot;;
print &quot;</td></tr></table></center>&quot;;
}
if ($t == 1) {
print &quot;</font><br><br>$sep&quot;;
}
if ($x == 1) {
print &quot;<br>&quot;;
print &quot;<h2><font color=0000ff>LEOM - Request Template - Understood</font></h2>&quot;;
print &quot;<table bgcolor=white cellspacing=2 cellpadding=1 border=4><tr><td colspan=2>&quot;;
print &quot;<b>Labmr:</b> &quot;,$query->textfield( -name=>'labmr', -size=>'8'),&quot;</td><td colspan=2>&quot;;
print &quot;<b>Initial meeting date:</b> &quot;,$query->textfield( -name=>'meetdate'),&quot;</td></tr>&quot;;
print &quot;<tr><td colspan=2><b>LEOM Planner: </b>&quot;,$query->textfield( -name=>'planner', -size=>'16');
print &quot;</td><td><b>Lab #</b> &quot;,$query->textfield( -name=>'labnum', -size=>'10');
print &quot;</td><td><b>MSC #</b> &quot;,$query->textfield( -name=>'msc', -size=>'10');
print &quot;</td></tr>&quot;;
print &quot;<tr><td><b>Technology</b>&quot;,$query->textfield( -name=>'technology', -size=>'12'),&quot;</td>&quot;;
print &quot;<td><b>Cell #</b>&quot;,$query->textfield( -name=>'understoodcellnum', -size=>'6'),&quot;</td>&quot;;
print &quot;<td><b>Cell Type</b>&quot;,$query->textfield( -name=>'celltype', -size=>'12'),&quot;</td>&quot;;
print &quot;<td><b>If other, specify</b>&quot;,$query->textfield( -name=>'typeother', -size=>'12'),&quot;</td></tr></table>&quot;;
print &quot;<br><table width=85% border=3 bgcolor=white><th colspan=2>Further Clarification Needed From Requester</th>&quot;;
print &quot;<tr><td colspan=3><font color=ff0000>Please do not enter colons :)) in the form!! Thank you!</td></tr><tr><td width=8%><b>Issue</b></td><td width=50%><b><center>Comments</center></b></td><td width=14%><b>Date Asked</b></td><td width=14%><b>Response Date</b></td><td width=14%><b>Questionner Sign-off</b></td></tr>&quot;;
print &quot;<tr><td><b>1</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment1', -size=>'60', -onBlur=>'this.form.comment1.value=filterColons(this.form.comment1.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked1', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response1', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner1', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>2</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment2', -size=>'60', -onBlur=>'this.form.comment2.value=filterColons(this.form.comment2.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked2', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response2', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner2', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>3</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment3', -size=>'60', -onBlur=>'this.form.comment3.value=filterColons(this.form.comment3.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked3', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response3', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner3', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>4</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment4', -size=>'60', -onBlur=>'this.form.comment4.value=filterColons(this.form.comment4.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked4', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response4', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner4', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>5</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment5', -size=>'60', -onBlur=>'this.form.comment5.value=filterColons(this.form.comment5.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked5', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response5', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner5', -size=>'10'),&quot;</td></tr>&quot;;
print &quot;<tr><td><b>6</b></td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'comment6', -size=>'60', -onBlur=>'this.form.comment6.value=filterColons(this.form.comment6.value)'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'asked6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'response6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td> &quot;,$query->textfield( -name=>'questionner6', -size=>'10'),&quot;</td>&quot;;
print &quot;<td>&quot;, $query->hidden( -name=>'hidden', -size=>'12'),&quot;</td></tr>&quot;;
print &quot;</table>&quot;;
print &quot;<br><hr><br><table width=85% border=3 bgcolor=ffffff><th colspan=3>Configuration valid and understood</th><tr><td width=10%><b>Team</b></td><td width=20%><b>Representative</b></td><td width=70%><b>Comments</b></td></tr>&quot;;

print &quot;<tr><td>MSC</td><td>&quot;, $query->textfield( -name=>'mscrep', -size=>'20'),&quot;</td>&quot;;

print &quot;<td>&quot;,$query->textfield( -name=>'msccomment', -size=>'70', -onBlur=>'this.form.msccomment.value=filterColons(this.form.msccomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>5E</td><td>&quot;,$query->textfield( -name=>'fiveerep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'fiveecomment', -size=>'70',-onBlur=>'this.form.fiveecomment.value=filterColons(this.form.fiveecomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Cell</td><td>&quot;,$query->textfield( -name=>'cellrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'cellcomment', -size=>'70',-onBlur=>'this.form.cellcomment.value=filterColons(this.form.cellcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Network</td><td>&quot;,$query->textfield( -name=>'netrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'netcomment', -size=>'70', -onBlur=>'this.form.netcomment.value=filterColons(this.form.netcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>ECP/ODA</td><td>&quot;,$query->textfield( -name=>'ecprep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield( -name=>'ecpcomment', -size=>'70',-onBlur=>'this.form.ecpcomment.value=filterColons(this.form.ecpcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>RF</td><td>&quot;,$query->textfield( -name=>'rfrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'rfcomment', -size=>'70', -onBlur=>'this.form.rfcomment.value=filterColons(this.form.rfcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Platform</td><td>&quot;,$query->textfield(-name=>'platformrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'platformcomment', -size=>'70', -onBlur=>'this.form.platformcomment.value=filterColons(this.form.platformcomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Power</td><td>&quot;,$query->textfield(-name=>'powerrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'powercomment', -size=>'70', -onBlur=>'this.form.powercomment.value=filterColons(this.form.powercomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Tools</td><td>&quot;,$query->textfield(-name=>'toolsrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'toolscomment', -size=>'70', -onBlur=>'this.form.toolscomment.value=filterColons(this.form.toolscomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Lab Planner</td><td>&quot;,$query->textfield(-name=>'labplannerrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'labplannercomment', -size=>'70', -onBlur=>'this.form.labplannercomment.value=filterColons(this.form.labplannercomment.value)'),&quot;</td></tr>&quot;;
print &quot;<tr><td>Mobiles</td><td>&quot;,$query->textfield(-name=>'mobilesrep', -size=>'20'),&quot;</td>&quot;;
print &quot;<td>&quot;,$query->textfield(-name=>'mobilescomment', -size=>'70', -onBlur=>'this.form.mobilescomment.value=filterColons(this.form.mobilescomment.value)'),&quot;</td></tr></table></center>&quot;;
print &quot;<br><table border=2 bgcolor=ffffff><th>Additional Comments</th><tr><td>&quot;,$query->textarea(-name=>'comments', -cols=>'75', -rows=>'8', -onBlur=>'this.form.comments.value=filterColons(this.form.comments.value)'),&quot;</td></tr></table><br>&quot;;
#$temp = $query->param('labmr');
#$default_name = $temp . '_understood.txt';
print &quot;<center><table><tr><td>&quot;,$query->textfield(-name=>'savefile'),&quot;&nbsp;&nbsp;&quot;;
#print &quot;<center><table><tr><td>&quot;,$query->textfield('savefile',$default_name),&quot;&nbsp;&nbsp;&quot;;
print &quot;<font color=0000ff><br>If you have completed the form and wish<br> to notify the group, check \'
Send Mail\'<br>&quot;;
print $query->checkbox(-name=>'mail_value', -label=>'Send Mail'),&quot;&nbsp;&nbsp;&quot;,$query->submit('action','SAVE'),&quot;</font></td></tr></table></center><br>&quot;;
}
} # show_form

sub get_input {
$i=0;
foreach $pair (split(/\&/,$ENV{QUERY_STRING})) {
($name[$i],$value[$i])=split(/=/,$pair,2);
$i++;
} # foreach
return ($labmr);
} # get_input

sub log_it {
$logstring.=localtime(time) . &quot;\t&quot; . join(&quot;\t&quot;,@_);
open(LOG, &quot;>>/logs&quot;)||die &quot;Can't write log:$!\n&quot;;
print LOG &quot;$logstring\n&quot;;
close(LOG);
} # log_it

sub print_output {
@_ = %FORM;
($firstname,$lastname,$email,$labmr, $default_name)=@_;
print &quot;<br>&quot;;
} # print_output

sub read_input {
&get_input();
$x=0;
$x++;
local ($buffer, @pairs, $pair, $name, $value, %FORM);
# Read in text
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
if ($ENV{'REQUEST_METHOD'} eq &quot;POST&quot;) {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}

# Split information into name/value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%(..)/pack(&quot;C&quot;, hex($1))/eg;
$FORM{$name} = $value;
}
%FORM;
&save_parameters($query);
} # read_input

print $query->endform;
print $query->end_html;
 
justice41 - got it working with the following code:


foreach $editCount (0..10) {
if ($query->param('action') eq 'EDIT'.$editCount) {
$query = &restore_parameters($query,$editCount);
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top