开发者

HTML form with multiple input fields

I have a html form which is populated using a java for loop. And it contains multiple input text type fields (email addresses) filled with the values which comes in a java arrayList from database. User can change the email addresses. The task at hand is, i have to first validate the addresses which are changed and then update the modified fields in the database.

Should i send all the field values to my action through request parameters. but how to send them all?

or any other way please.

p.s. im using struts1. if there is any way through struts please tell me开发者_StackOverflow社区.

Thanks.


So, I think you're asking how to track which e-mail was changed/replaced with a new value, correct? If so:

You could set name attributes on each of them with the index they match with in the array. <input name="email1" ...> <input name="email2" ...> etc.

Or if the array is unordered, you can add a <input type=hidden ...> that contains the original e-mail for each visible with matching indexes appended to their form name attributes. <input name="email1" ...> <input name="email_orig1" ...>

Or if the e-mail addresses come from a data source with a unique key you could use that: <input name="email_1234" ...> where 1234 is the unique id from you data source.

You can send them via GET or POST--though I highly recommend POST since it changes data so using a GET would technically be against HTTP specs. Either way you're going to have to process them one by one on the server-side; you can't have them automatically applied and updated since they don't have fixed names.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜