in reply to Insert into table when user clicks one of many submit buttons

You'll have to show us your form HTML to get more than a guess, but here's one: do your hidden fields have the same name attribute, like this?

<input type='hidden' name='cat_num' value='track1' /> ..... <input type='hidden' name='cat_num' value='track2' />

If that's the case, the browser may send the first value, or the last one, or do something random. I'm not sure the behavior is defined in the case of multiple input fields having the same name, but I am sure that's not going to work very well.

There are a couple of different ways to fix that, but first I'd look at what you're trying to do. Presumably you want to know which track(s) the user has selected. If you only want one track selected at a time, you can get rid of the hidden fields and give each submit button a different name, like "submit_track1", and parse that key to find out which one was clicked. If you want to allow multiple tracks to be checked, you'll need to put checkboxes next to them, or something that lets the user select a quantity. In that case, you would put the track name in the checkbox or other input field, and again would not need the hidden field. In fact, it's hard to see how hidden fields would help you here, since you need to use fields the user can interact with, to tell you which track(s) he wants.

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.

Replies are listed 'Best First'.
Re^2: Insert into table when user clicks one of many submit buttons
by tinita (Parson) on Nov 28, 2011 at 11:59 UTC

      Thanks for the correction. I reckoned that's how it worked, since other field types work that way; but I didn't take the time to look it up because it wouldn't have solved his problem. Treating it as an array would give him the values of all his hidden fields instead of only the first one, but that still wouldn't tell him which item(s) was selected. I should have mentioned it, though.

      Aaron B.
      My Woefully Neglected Blog, where I occasionally mention Perl.

Re^2: Insert into table when user clicks one of many submit buttons
by ironside (Acolyte) on Nov 28, 2011 at 03:44 UTC

    Yes my hidden fields did have the same name. I didn't think to make the submit buttons unique and parse it that way. I saw a example using hidden fields and thought that might be the way to go. Thanks for the help.

Re^2: Insert into table when user clicks one of many submit buttons
by Anonymous Monk on Nov 28, 2011 at 09:20 UTC

    [same name attribute] the browser may send the first value, or the last one, or do something random.

    I believe the standard says that they shall send them all. (This is at least the situation with checkboxes.) CGI.pm can then return those values as an array.