Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 231583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:56:43+00:00 2026-05-11T19:56:43+00:00

I am using Struts2 tags for my designing page at front end side. Now

  • 0

I am using Struts2 tags for my designing page at front end side.

Now i have a requirement for in my jsp page that i have put 3 simple fields & on some add link i want to so repetitively some another 3 or 4 field at same form dynamically.

For example if user clicks 5 time on add link then 5 time that 3 or 4 field have to show on jsp page.

I know ajax can be useful for this purpose. But still i am confused that how to achieve it.

Plz reply if any one have solution…

thanx in advance….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:56:43+00:00Added an answer on May 11, 2026 at 7:56 pm

    Your best approach would be to use jquery to simplify the javascript. This simple html page demonstrates the approach:

    <html>
      <head>
        <script type="text/javascript" src="js/jquery-1.3.2.min.js"/>
      </head>
      <body>
        <form method="post" action="#">
          <table>
            <tbody> 
              <tr>
                <td><input type="text" name="fieldname"/></td>
                <td><a href="#" onclick="$(this).closest('tr:not(:only-child)').remove();return false;">delete</a></td>
              </tr>
              <tr>
                <td><input type="text" name="fieldname"/></td>
                <td><a href="#" onclick="$(this).closest('tr:not(:only-child)').remove();return false;">delete</a></td>
              </tr>
            </tbody>
            <tfoot>
              <tr>
                <td></td>
                <td><a href="#" onclick="var tr = $(this).closest('table').find('tbody tr:first-child').clone(true); $(tr).find(':input').val(''); $(this).closest('table').find('tbody').append(tr); return false;">add</a>
                </td>
              </tr>
            </tfoot>    
          </table>
        </form>
      </body>
    </html>
    

    This is a quick rundown of the approach. Each repeating element is part of row in a table. You can choose any other type of container adjusting the jquery accordingly. The repeating elements are within the tbody in each row there is an input and a link that deletes that row. Notice that it will delete the row only if it is not the only child of tbody. We need this to always have a way to add a new element from the add link. The add logic is in the tfoot. The add link finds the first table row in the corresponding tbody, clones it, clears all the values in any input fields and appends it to the tbody as a new row.

    It is not good practice to embed that much javascript/jquery into an attribute as I did in this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well.. we've developed a j2ee application using struts2 ajax capabilities. We find that the
I am using struts2 to build a web application and I use struts2 tags
I am using strus2 tags in a jsp to iterate over a collection: <s:if
Using struts2 with jsp with standard struts tag libraries. I'm trying to dynamically hide
I am using Struts2 for a web application development. i have this particular problem
While using Struts2, I am using several annotations to do my validations inside the
I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have
I'm writing a website in JSP using Struts and Hibernate. I'm looking for a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.