This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

logic:iterate, add new input fields to a jsp

 
Jim Kernsey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic