open a modal window in jsp

Tom picture Tom · Feb 29, 2012 · Viewed 16.5k times · Source

I was able to find one solution regarding modal windows, here is the link: Simple jQuery Modal Window Examples. However, what I want specifically is:

  • I want to open b.jsp as a Simple Window Modal, like the one given in that website link above.
  • After clicking the submit button I want b.jsp to open in that manner.

I tried several solutions, but I can't get it to work the same way.

Here is my code below:

a.jsp

<form action="b.jsp">
<input type="submit" value"click here to open modal window"/>
</form>

Answer

V&#237;ctor Due&#241;as Robles picture Víctor Dueñas Robles · Feb 29, 2012

Using JQuery UI is very easy.

I do some changes:

Change type to button because you don´t nee sudmit form for load html.

<div id="resultreturn" style="display: none"></div>
<form >
<input type="button" value="click here to open modal window" id="loader"/>
</form>

Later I bind a event click an in this event:

$(document).ready(function(){
    $("#loader").click(function(){
                // Load the page into the div
        $("#resultreturn").load("b.html");
                // Show the modal dialog
        $("#resultreturn").dialog({ modal: true });
    });
});

I hope this help you