Hey guys, So I have run into a weird issue and was wondering if anyone could help me... I have a segment of code which is designed to test data using PERL in a MASON file. The concept is that when the user enters a item for deletion, the PERL code identifies it and alerts the user to the number of items to delete... Here is a breakdown of the code:
% # my $tab_id is set higher in the code^^^ % my $foo = $c->req->param('foo'); % my $bar = $c->req->param('bar'); % my $baz = $c->req->param('baz'); % my @update = split(/,/, $c->req->param('biz'); #this is an array o +f place to delete # the items % if ( ($foo) && ($baz == 2) && (and{$tab_id == $_}@update) ) { % my @delete_items = split (/,/, $foo); % my $del_count = scalar(@delete_items); deletes += <%$del_count%>; # this is setting the JS variable f +or the counts % } % if ( ($bar) && ($baz == 2) && (and{$tab_id == $_}@update) ) { % my @delete_items = split (/,/, $bar); % my $del_count = scalar(@delete_items); deletes += <%$del_count%>; % } --------------------------------------------------------------------- +------------ // javascript section: if(deletes > 0) { return confirm('Delete ' . + deletes + . 'Items? '); }
for a bit of context here $foo, $bar are the input from the form and this section of code is executed along with other stuff on the user hitting submit on the form. My issue is that the code works, but it doesn't alert properly. its a bit hard to explain so I will just give an example.. Say I enter 3 items to be deleted and press submit. No error will pop up to alert me. But say I go back to the page and try to delete a single item, the alert will pop up and say 'Delete 3 Items? ' When I dump the variable contents to the log, the variables contain data from the first submission and not the second (correct) submission. This continues... Every time I do an operation on the page, the data that the alert operates on is one 'session' behind... The alert works, and it is getting the expected data but just needs to operate on the correct update... I am unsure if this is an issue with the way Catalyst is handling the data or what, but I could sure use some help... Thanks!!!

In reply to Help with Perl/Catalyst/Mason by sharkeyph

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.