Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Passing String Parameter to javascript function in jsp is not working
I have one JSP file This file contains some below code.
<%
String data = "some data from database";
%>
<aui:input type="checkbox" name="isOption" label="isOption" onChange="javascript:onChangeCheckBox('<%= data %>');"></aui:input>
<script>
function onChangeCheckBox(input)
{
console.log("Input------------>"+input);
}
</script>
When I have a checking or unchecked the
checkbox from UI it will call the onChangeCheckBox function and print
the input on the console.
But instead of printing the actual string, it will be printing the below output on the console.
Input------------><%= data %>
If memory serves me right, having scriptlet in tags requires the whole value to be a scriptlet.
E.g. instead of
<some:thing key="some <%="value"%>"/>
you'd need
<some:thing key="<%="some " + "value"%>"/>
or similar
Thanks for your answer issue is now resolved
Hello, replace this
<% String data = "some data from database"; %>
javascript:onChangeCheckBox('<%= data %>')
with
${data = "some data from database"}
javascript:onChangeCheckBox('${data}')
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™