Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda