File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes logic:iterate, add new input fields to a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate, add new input fields to a jsp" Watch "logic:iterate, add new input fields to a jsp" New topic
Author

logic:iterate, add new input fields to a jsp

Jim Kernsey
Greenhorn

Joined: Jul 12, 2006
Posts: 1
Hi

I have a jsp where i need to enter multiple items, each item has four properties. I don't know how many items i will need to enter before the page is created and I want to have a page where I initially provide the user with 5 input rows and if the user wishes to add more than five items, they can press a button wich then adds a new row for input of an item. So after pressing the button they would have 6 rows for inputting items and this process can be repeated.

The code I have so far is, where counter is set to 5 initially.



I'd be greatful If you could help me with this.

Regards

Jim K
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
I can think of two options when the user attempts to add a new row:

The first option would be to submit the form to an action that increments the size of the list, and then forwards back to the same page. This should be pretty easy to implement, but would cause the screen to reload every time they add a row.

The secoud option would be to call a javascript function that uses innerHTML to dynamically create a new row. This method would require a little more work than the first option, but the screen wouldn't have to refresh.

Let me know if you have any questions about either method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic:iterate, add new input fields to a jsp