jck has asked for the wisdom of the Perl Monks concerning the following question:

hope there is a simple solution - i'm sure i'm just overlooking something obvious.

my objective is to move individuals from an organization into committees, and to promote committee members to chairman positions. the form ultimately has three scrolling list select menus, and the buttons move members from one to another. i'm currently working on moving members out of the committee list back to the organization list. haven't started on the chairman assignment until i get this direction worked out.

print div({-class=>'taskcolumnleft'}, h3("Chair(s) of<br>$name committee"), start_form({-action=>"/memberarea/cmt/members/edit/"}), hidden(-name=>'requestID',-value=>$requestID), $currentchairlist, submit(-name=>'submit',-value=>'Remove Chairs')); end_form; print div({-class=>'taskcolumncenter'}, h3("Current Members of<br>$name committee"), start_form({-action=>"/memberarea/cmt/members/edit/"}), hidden(-name=>'requestID',-value=>$requestID), scrolling_list(-name=>"currmembers", -value=>$mbrArray, -size=>20, + labels=>$mbrHash, -multiple=>"true"), p( [ submit(-name=>'submit',-value=>'<<= Assign as Committee Chair' +), submit(-name=>'submit',-value=>'Remove Members =>>') ]), end_form); } print div({-class=>'taskcolumnright'}, h3("Members<br>(not on this committee)"), start_form({-action=>"/memberarea/cmt/members/edit/"}), hidden(-name=>'requestID',-value=>$requestID), scrolling_list(-name=>"addmember", -value=>$nocIDArray, -size=>20, + labels=>$nocNameHash, -multiple=>"true"), p(submit(-name=>'submit',-value=>'<<= Add Members')), end_form);

and my processing functions are as follows;

sub add_members { foreach (@addmembers) { my $sql = "INSERT INTO cmt_members (CmtID, MemberID)"; $sql .= "VALUES ($requestID, $_)"; my $sth = $dbh->prepare($sql) || die "Error preparing: $DBI::errstr"; $sth->execute || die "Error executing: $DBI::errstr"; } } sub remove_members { print p("we're in the remove members function"); foreach (@currmembers) { print p($_); my $sql = "DELETE FROM cmt_members WHERE MemberID = $_ and Cmt +ID = $requestID"; print p($sql); $sth = $dbh->prepare($sql) || die "Error preparing: $DBI::errstr"; $sth->execute || die "Error executing: $DBI::errstr"; $requestID = $requestID; } }

the "add_members" function works great - the "remove_members" doesn't

i have tested what post-data is being passed, and the @addmembers array works, but the @currmembers doesn't. i put in the line "print p("we're in the remove members function"), to test if it's being called, and it is, but @currmembers is empty.

Replies are listed 'Best First'.
Re: CGI: multiple forms on page
by Unforgiven (Hermit) on Jul 27, 2009 at 13:47 UTC
    I'm convinced that there's a universal law of the universe that says that within seven seconds of asking someone else what you're doing wrong, you'll think of it yourself. Even if you've spent days on it until then.
      There's another law that says however many times you read the docs it is only when somemonk on here tells you to read them that a paragraph magically appears clearly answering your question.
Re: CGI: multiple forms on page
by jck (Scribe) on Jul 26, 2009 at 19:31 UTC
    oops - nevermind. the answer WAS obvious!!! i didn't declare the variable @currmembers in the params that was passed, so, of course, the page never knew it was there!!

    can i delete this node??

      No, that's frowned upon.

      But your discovery after posting is another reminder of the proposition that stating (and re-stating) a problem, even to yourself, often yields a heretofore unrecognized answer or issue. So let it be, for future readers.