• Post Reply Bookmark Topic Watch Topic
  • New Topic

When I post hidden field of form its giving same record instead of different records

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to submit the form data. form method is post.

input type=hidden always send same accountId whereas in view source of html it displays correctly. I mean there are many records and each record has its own account Id that is generated my servlet as HTML but when form is submitted it always get the first record accountId despite of different accountId's for different records.

Please advise

Best regards
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're mistaken. Not one accountId is sent, but all of them are. You are only retrieving the first though. Just check what request.getParameterValues("accountId") returns. The reason for this is because you have one form with many fields of the same name.

I know of two ways to solve this:
1) Use one global accountId field. Upon pressing one of the edit buttons, you use JavaScript to set its value before submitting.
2) Rename your buttons to include the accountId in the button name. For example, editPayment_123. In your processing code you must then go through all parameters to see which editPayment button is pressed (if any).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!