0

In my jsp, I have something like this

<%
String isMultipleOfficesExists = (String)request.getAttribute("MultipleOfficesExists");
        String isMultipleOfficeSecurity = (String)request.getAttribute("MultipleOfficeSecurityExists");
String envParm = "default";
if("true".equals(isMultipleOfficesExists)){
    envParm = "multipleOffice";
}else if("true".equals(isMultipleOfficeSecurity)){
    envParm = "multipleOfficeSecurity";
}
%> 

At the bottom of my form, in my submit button, I am calling a JavaScript On-click function.

<input class="white_button_extra_large" type="button" value="<%=goBtn%>" onclick="javascript:selectEnvironment(envParm);">

And my script section is :

function selectEnvironment(envParm)
{
    resetToken();
    logoutFlag = false;
    document.forms[0].action = contextURL+'/login/selectEnvironment?envParam=' +envParm;
    document.forms[0].submit();
}

But I am getting Uncaught ReferenceError: envParam is not defined

How can I solve this?

1 Answer 1

1

Make your envParm variable global in JSP. And your on click event should be like follows

<input class="white_button_extra_large" type="button" value="<%=goBtn%>" onclick="javascript:selectEnvironment('<%=envParm%>')">

You should pass the value from javascript function. The parameter should have value. Refer this linkPassing arguments

Sign up to request clarification or add additional context in comments.

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.