I am a beginner in perl. I am getting problem while maintaining a state information of web form. Below is the partial code that i am using in my script using CGI module.
if(param('listName')){ $listvalue = param('listName'); $current = "/Desktop/$listvalue"; find (\&processFiles, $current); &processData(); }else{ print "Content-type: text/html\n\n"; if(param('txtName')){ @txtvalues = param('txtName'); }else{ @txtvalues = param('tName'); print @txtvalues;} %data = param('hashdata'); print @txtvalues; &manageStateProcess(); } sub processData() { while ((my $keys, my $values) = each(%data)){ $comment=""; if($values =~m/(.*?\s)\ *(\#.*)/){ $values="$1";$comment="$2";} if ($keys =~m/^.*File.*$/){ #$check{$keys}=$values; push(@checkbox_rows, td([table(font({-color=>"blue"},$keys +)),table(checkbox(-name=>"",-value=>$values,-size=>15)),table($commen +t)])); }else{ push(@textfield_rows, td([table(font({-color=>"blue"},$key +s)),table(textfield(-name=>'txtName',-value=>$values,-size=>25)),tabl +e($comment)])); } } } sub manageStateProcess() { my $i=0; my %hashtextField; while ((my $keys, my $values) = each(%data)){ $comment=""; if($values =~m/(.*?\s)\ *(\#.*)/){ $values="$1";$comment="$2";} if ($keys =~m/^.*File.*$/){ push(@checkbox_rows, td([table(font({-color=>"blue"},$keys +)),table(checkbox(-name=>"", -value=>$values,-size=>15)),table($comme +nt)])); }else{ my $values = $txtvalues[$i]; print "<b>$values<b>"; $i++; push(@textfield_rows, td([table(font({-color=>"blue"},$key +s)),table(textfield(-name=>$keys,-value=>$values,-size=>25)),table($c +omment)])); #hidden(-name=>'tdata', -values=>[@text]); } } } print header; print start_html('N1 Grid'); print h4({-align=>'center'},'N1 Grid'); print hr; my $a="Test"; if ($a){ print h1({-align=>'center'},$a); } print p{-align=>'RIGHT'},a({-href=>"parsecfg.pl"},"Go to home page" +), start_form(-method=>"POST", -action=> 'cfgdata13.pl'), table({-align=>'CENTER',-valign=>'TOP'},Tr(\@checkbox_rows)), table({-align=>'CENTER',-valign=>'TOP'},Tr(\@textfield_rows)), hidden(-name=>'hashdata', -values=>[%data]), p{-align=>'CENTER'}, submit, end_form; print end_html;
Here is what I want exactly. Every time when I submit the form, it should maintain the previous record. In my form, I am creating a numbers of textfield and I want to maintain each value with its previous record while submitting a form. Is there a way can I access a list of textfield value by using array like @textvalues=param($keys); or is there any other way to pass textfield name for each value in a loop. currently I am using "push(@textfield_rows, td(table(font({-color=>"blue"},$keys)),table(textfield(-name=>$keys,-value=>$values,-size=>25)),table($comment)));" but, I cannot access textfield value while declare as textfield(-name=>$keys,,-value=>$values). Help needed senior monks, Thanks in advance.

In reply to Maintain State Information by sandipgd

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.