No i have made a script that searches /var/www/html/bestellingen/ingezet/ for files
it displays the files and then the user has three options
do nothing (niets)
place the file in /var/www/html/bestellingen/postvak_uit (verzenden)
or place the file in /var/www/html/bestellingen/nakijken (nakijkeną
The script works fine but when i push the submit (verwerken) button the screen needs to refresh and that does not work i have a set to defaults button when i push it everything is ok
Here is my code it is probably the ugliest code you ever seen but i'm not a programmer and new to perl
#!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard :html3/; use File::Copy; $waarbestel='/var/www/html/'; $path_to_files='/var/www/html/bestellingen/ingezet'; $q = new CGI; &zoekfiles ($path_to_files); sub zoekfiles { $path1= shift @_; #het path waar de files staan my %berichten = &listfiles ($path1); @hoofdingen= ('Bon','Fax','Mail.','Leverancier','Lev. nr.','Actie'); @rijen = th(\@hoofdingen); foreach my $berichtbestelbonnr (keys %berichten) { for my $berichtrol (keys %{$berichten{$berichtbestelbonnr}} ) { #print "$berichten{$berichtbestelbonnr}{$berichtrol} " ; $fax1 = "$berichten{$berichtbestelbonnr}{$berichtrol} " if ($beric +htrol eq 'fax'); $mail1 = "$berichten{$berichtbestelbonnr}{$berichtrol} " if ($beri +chtrol eq 'mail'); $lev1 = "$berichten{$berichtbestelbonnr}{$berichtrol} " if ($beri +chtrol eq 'leverancier'); $levnr1= "$berichten{$berichtbestelbonnr}{$berichtrol} " if ($beri +chtrol eq 'leveranciersnummer'); $link1= "$berichten{$berichtbestelbonnr}{$berichtrol} " if ($beric +htrol eq 'link'); } $verwijzing= a({-href=>"http://localhost/$link1", -style => 'color: blue;' },"$berichtbestelbonnr"); $actie=popup_menu(-name=>"$berichtbestelbonnr", -values=>['niets','verzenden','nakijken'], -default=> 'niets'); push (@rijen,td([$verwijzing,$fax1,$mail1,$lev1,$levnr1,$actie])); } print $q->header; print $q->start_html (-title =>'Bestellingen die ingezet werden', -BGCOLOR=>'cyan'), $q->a({-href=>"t12.pl"},"Ingezet"), " - ", $q->a({-href=>"t1.pl"},"Postvak-Uit"), " - ", $q->a({-href=>"t1.pl"},"Verzonden"), " - ", $q->a({-href=>"t1.pl"},"Bevestigd"), " - ", $q->a({-href=>"t1.pl"},"Nakijken"), $q->p, $q->h1({-style=>'Color: blue;'},'Bestellingen die ingezet werd +en'), $q->p, $q->start_form; print $q->table({-border=>undef,-width=>'95%'}, Tr(\@rijen) ), $q->submit(-name=>'Doorsturen', -value=>'Verwerken'), $q->defaults('Defaults'), $q->end_form, $q->hr; print $q->end_html; $verwerken = param('Doorsturen'); if ($verwerken =~ 'Verwerken') { foreach my $berichtbestelbonnr (keys %berichten) { $popup_menu_waarde=$q->param("$berichtbestelbonnr"); $file_to_proces=$berichten{$berichtbestelbonnr}{'link'}; $file_to_proces=~s%bestellingen/ingezet/%%; if ($popup_menu_waarde eq 'verzenden') { #print "$path_to_files$file_to_proces===>/var/www/html/bestelling +en/postvak-uit/$file_to_proces"; move("$path_to_files/$file_to_proces", "/var/www/html/bestellinge +n/postvak-uit/$file_to_proces"); }elsif ($popup_menu_waarde eq 'nakijken') { move("$path_to_files/$file_to_proces", "/var/www/html/bestellinge +n/nakijken/$file_to_proces"); } #print "Verwerkt"; } print "Verwerkt"; # here in need to set the screen to defaults or refresh the screen } } sub listfiles { #haal de directorY $dirtolist= shift @_; $_=$dirtolist; s%/var/www/html/%%; $reldir=$_; #print "\n dir delete $dirtoempty\n"; $extension_to_list= "pdf"; opendir (DIR,"$dirtolist"); @files = grep(/.*$extension_to_list$/, readdir (DIR)); foreach (@files) { my $filename=$_; $linktofile="$reldir/$filename"; if (m%---\d+.pdf%g) { #bestelbonnummer $_= $& ; s%.pdf%%; s%---%%; $bestelbonnummer=$_; #print "bestel: $_\n"; $_=$filename; s%---$bestelbonnummer.%.%; $filename= $_; } if (m%---\d+.pdf%) { #leveranciersnummer $_= $& ; s%.pdf%%; s%---%%; $leveranciersnummer=$_; #print "levnr: $_\n"; $_=$filename; s%---$leveranciersnummer.%.%; $filename= $_; } if (m%---\w+.pdf%) { #leverancier $_= $& ; s%.pdf%%; s%---%%; $leverancier=$_; #print "lev: $_\n"; $_=$filename; s%---$leverancier.%.%; $filename= $_; } if (m%---\d+.pdf%) { #fax $_= $& ; s%.pdf%%; s%---%%; $fax=$_; #print "fax: $_\n"; $_=$filename; s%---$fax.%.%; $filename= $_; } if (m%\w+@\w+.\w+.pdf%) { #mail $_= $& ; s%.pdf%%; s%---%%; $mail=$_; #print "mail: $_\n"; $_=$filename; s%---$mail.%.%; $filename= $_; } $bestelling {$bestelbonnummer} = { 'leveranciersnummer' => $leveranciersnummer, 'leverancier' => $leverancier, 'fax' => $fax, 'mail' => $mail, 'link' => $linktofile }; } #print @files; closedir (DIR); return (%bestelling); }

In reply to Re^2: CGI.PM automaticly reset form to Defaults by harryC
in thread CGI.PM automaticly reset form to Defaults by harryC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.