Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
JSP - Passing values to modal on the same page

I have a jsp page that contains a username and a button, When I click on the button I want to pass the username to the modal then in the click on the modal button I send the username to the back-end (struts2 action). (Scenario illustrated in the below picture)

I tried to pass username with onClick :

<%-- Page.jsp --%>
<button onclick="document.forms[0].username.value='BOB'; toggle="modal" data-target="#myModal">
   <fmt:message key='Delete user'/>
</button>
<jsp:include page="deleteUserModal.jsp"/>

On the modal I want to read unsername value :

<%-- Modal.jsp --%>
<button onclick="document.forms[0].username.value='???';document.forms[0].action='deleteMethod';document.forms[0].submit();">
  <fmt:message key='delete'/>
</button>

Any idea please,

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You trying to access elements from the another window. To customize the modal content you should use HTML data-* attributes. See how to use verying modal content with bootstrap.

<button onclick="document.forms[0].username.value='BOB'; toggle="modal" data-target="#myModal" data-username='BOB'>
   <fmt:message key='Delete user'/>
</button>
$('#myModal').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) 
  var username = button.data('username') 
  var modal = $(this)
  modal.find('.modal-body button').click(function(){
    alert(username);
})
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!