Forms, Perl. Data in the <select> tag disappears after submit.

In the following code, the data in the second set of <select> tag disappears after I click on the submit button. How can I stop tha browser from doing that?

#!/usr/bin/perl

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print header, start_html;

#Get option of select
$SelectedValue=param('sel0') or "";

#Open servers' list
open(DAT, "<ServerList.txt") or die "<ServerList.txt $!";

@eek=<DAT>;
print "<table border=1><tr>";
print "<td>";
print "<form action=some.pl method=post>";
print "<select size=10 id=a name=sel0>";
foreach(@eek)
{
print "<option>";
print;
}
print "</select>";
print "<input type=submit id=gv>";
print "</form>";
print $SelectedValue;

print "</td>";
print "<td>";

$thing="cleartool lsvob -s -host ";
if ($SelectedValue eq ""){
#$thing="";
}
else{
$thing=$thing . $SelectedValue;

@aak=`$thing`;

open (DUT, ">ee.txt") or die ">ee.txt $!";
foreach $pu (@aak){
print DUT "$pu";
}
close DUT;

open (DUT, "<ee.txt") or die "<ee.txt $!";
@aok = <DUT>;
close DUT;
}

print "<form action=some.pl method=post>";
print "<select size=10 id=a name=sel1>";
foreach (@aok)
{
print "<option>";
print;
}
print "</select>";
print "<input type=submit id=gv1>";
print "</form>";
$SelectedValue1=param('sel1') or "";
print $SelectedValue1;
print "</td>";
print "<td>";

$thing1="cleartool lstype -short -kind trtype -invob vob:";
if ($SelectedValue1 eq ""){
#$thing1="";
}
else{
$thing1=$thing1 . $SelectedValue1;

@ook=`$thing1`;

}
print "<form action=some.pl method=post>";
print "<select size=10 id=a name=sel2>";
foreach(@ook)
{
print "<option>";
print;
}
print "</select>";
print "<input type=submit id=gv2>";
print "</form>";
$SelectedValue2=param('sel2') or "";
print $SelectedValue2;




print end_html;


n4narikAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
geotigerConnect With a Mentor Commented:
It seems that the select in the second form depends on the command in '$thing'. If it is empty, you will get empty select.

The $thing is executed only if you have something selected in sel0 parameter. Check the value in $SelectedValue.


0
 
ozoConnect With a Mentor Commented:
$SelectedValue1=param('sel1') or "";

$thing1=$thing1 . $SelectedValue1;

@ook=`$thing1`;

can be very dangerous
What if a user sends something like param('sel1') = '; rm -r *'
0
 
n4narikAuthor Commented:
I would like to close this question as I didn't get satisfactory results from the users.
Help me admin.
0
 
ozoCommented:
What do you find unsatisfactory?
Perhaps you need to clarify your question.
0
All Courses

From novice to tech pro — start learning today.