0

I have the following line in my JSP file:

<input type="button" name="btnNew" value="Új" class="button" onClick="clickSubmitButton('newRow'); isRowExists(<%tblMgr.isRowInDueCauseTable(request);%>)">

The isRowInDueCauseTable(request) method is returning a boolean value, but I'm not sure if I'm passing the boolean value to the javascript isRowExists function correctly, because I always get undefined, when I try to evaluate:

function isRowExists( isRowInDatabase ) {
        console.log(isRowInDatabase);
        if (isRowInDatabase == true) {
            alert('Already in database');
        }
    }

How can I pass the java methods return value to the JavaScript function in JSP?

2 Answers 2

1

The correct syntax needs the equal character(=) to write a value.

See:

Incorrect way:

<%tblMgr.isRowInDueCauseTable(request);%>

Correct way:

<%=tblMgr.isRowInDueCauseTable(request)%>

Then:

<input type="button" name="btnNew" value="Új" class="button" onClick="clickSubmitButton('newRow'); isRowExists(<%=tblMgr.isRowInDueCauseTable(request)%>)">
Sign up to request clarification or add additional context in comments.

Comments

0

try AJAX, you can set your text(value to return) to request and then read it in javascript function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.