in reply to process multiple rows from form

Maybe I simply don't understand what you want to achieve. It looks to me like you got several input fields on a web page, all with the same name, but with different id. Now you want to read the submitted form in your CGI and want to get the id, not the name.

AFAIK the id is not submitted, so no way to read it. You will have to make the name the id (or append the id to the name) in order to get that info.

$\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print

Replies are listed 'Best First'.
Re^2: process multiple rows from form
by boboson (Monk) on Sep 27, 2005 at 04:54 UTC
    here is a small example:
    <form name="myform" method="post" action="index.cgi"> <input type="hidden" name="rm" value="doSomething"> <TMPL_LOOP NAME="LOOP_DATA"> <input name="name<TMPL_VAR NAME=objectid>" value="<TMPL_VAR NAME=compu +ter>"> <input name="price<TMPL_VAR NAME=objectid>" " value="<TMPL_VAR NAME=pr +ice>">"> <input name="qty<TMPL_VAR NAME=objectid>" " value="<TMPL_VAR NAME=qty> +">"> </TMPL> </form>
    There must be a cleaner solution to process a form like this than the above solution where I append the objectid to the input name attribute. I thought I could use the id attribute somehow but apparently not.

      I do something similar. Generaly I throw a _ in the name so its 1_price. Then loop over it spliting them out. Probably some easier way to do it, but I've sued something similar to the following.

      my $ids = {}; my @params = $cgi->param(); foreach my $param ( @params ) { my ($id, $field) = $param =~ /^(\d+)_(.*)$/; $ids->{$id}->{$field} = $cgi->param($param); }

      Depending on the values you could get and how you want to handle them you might need to check for the lenght of the return value. YMMV


      ___________
      Eric Hodges