Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
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
Passing String Parameter to javascript function in jsp is not working
Jamie Sammons, modifié il y a 4 années.
New Member
Publications: 3
Date d'inscription: 03/04/22
Publications récentes
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 %>
Olaf Kock, modifié il y a 4 années.
Liferay Legend
Publications: 6441
Date d'inscription: 23/09/08
Publications récentes
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
Jamie Sammons, modifié il y a 4 années.
New Member
Publications: 3
Date d'inscription: 03/04/22
Publications récentes
Thanks for your answer issue is now resolved
Jamie Sammons, modifié il y a 4 années.
Junior Member
Publications: 39
Date d'inscription: 09/03/22
Publications récentes
Hello, replace this
<% String data = "some data from database"; %>
javascript:onChangeCheckBox('<%= data %>')
with
${data = "some data from database"}
javascript:onChangeCheckBox('${data}')
Community
Company
Feedback