Fahad
Fahad

Reputation: 403

Load a jsp on div element on checkbox

I need to load a jsp page on a div element if any checkboxes=checked if unchecked hide the div element. So far I have attempted this but its not working at all! HELP!

JS:

    $(document).ready(function(){
$.each($("input[type=checkbox]:checked"),function(){
    $("verification").load("/selectionPage");
});

JSP:

<td class="cb" bgcolor='<c:out value="${summary.color}"></c:out>'><input
                        type="checkbox" value="">
                    </td>
                </tr>
            </c:forEach>
    </tbody>
</table>
       </div>
     <div id="verification"></div>

Upvotes: 0

Views: 1103

Answers (1)

user504674
user504674

Reputation:

Please read the inline comments too.

$(document).ready(function () {
    $("input[type=checkbox]").click(function () {

        //things you want to do when the checkbox is checked
        //like loading the jsp
        if ($(this).attr('checked') === 'checked') {

            //make sure the selector is correct. # for id, . for class etc.
            //also, /selectionPage or /selectionPage.jsp?
            //Basically, path resolver or hitting JSPs directly?
            $('#verification').load('/selectionPage.jsp', function () {
                console.log('done');
            });
        }

        //things you want to do when the checkbox is unchecked
        //like maybe clearing the div?
        else {
            $('#verification').html('');
        }
    });
}

Upvotes: 1

Related Questions