From a form like that I need to keep the components together that end in the same number so I can do something with it from the database. I found a mailing list post that suggested the following, but I kept getting an error from it:<form method="get" action="test_list.html"> <input type="hidden" name="LineItem" value="1" /> First Number: <input type="text" name="first-1" /><br /> Second: <input type="text" name="second-1" /><br /> Third: <input type="text" name="third-1" /> </p> <p> <input type="hidden" name="LineItem" value="2" /> First Number: <input type="text" name="first-2" /><br /> Second: <input type="text" name="second-2" /><br /> Third: <input type="text" name="third-2" /> </p> <input type="submit" name="a" value="go"> </form>
I tried a few things but my main problem was getting the LineItem variable into an array (not an array of arrays). So it only gets one of the sets of variables.foreach (values $ARGS{LineItem}) { $SQL->execute( $PONum, $ARGS{"first-${i}"}, $ARGS{"second-${i}"}, $ARGS{"third-${i}"} ); }
I am guessing I am getting CLOSE, but I can't quite complete it without some help. Thanks!my @lineitems = $ARGS{"LineItem"}; foreach my $line (@lineitems) { print "line is @$line[0]"; print $ARGS{"first-@$line[0]"}; print $ARGS{"second-@$line[0]"}; print $ARGS{"third-@$line[0]"}; }
In reply to Parsing cgi variable lists by inblosam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |