Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

dynamic JSP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I have a requirement wherein I need to dynamically create a row containing: a Select box (drop down) and a Textbox dynamically every time a button (say Add row) is clicked.

It looks something like this:

Column1 Column 2 Column 3
Select box1 Text Box1 Add New Row1
Select box2 Text Box2 Add New Row2
.
.
SelectboxN TextBoxN Add New RowN

Example: when i have first 2 rows and I click Add New Row2, a 3rd row is created.

I use Struts for coding my jsp page.
Does this require Ajax or can it be done using Javascript itself?
Any links for similar examples could also be helpful.

Thanks in advance.
Ram
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're just creating a new row on the page, this can be done by manipulating the Document Object Model (DOM) with JavaScript. If you're not familiar with how to modify pages dynamically using the DOM, this link will provide some basic information to get you started.

Even though you used Struts to create the page originally, remember that JavaScript operates on the Plain HTML tags that were rendered by struts, not the struts tags themselves. Use your browser's "view source" facility to see the actual HTML that is on the page.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic