The following code does not show the alert of "abc" but there is no any error message? Any idea to solve it?
<%@ include file="includes.jsp"%>
<script src="js/bootstrap-datepicker.js"></script>
<link href="css/bootstrap-datepicker.css" rel="stylesheet" />
<script src="js/jquery.dataTables.min.js"></script>
<link href="css/jquery.dataTables.min.css" rel="stylesheet" />
...
...
$("input[name=rnrInd]").change(
function() {
if ($(this).is(":checked")) {
alert(${fn:substring("abcxyz", -1,3)});
$("input[name=mnpCustName]").val("PREPAID SIM");
$("input[name=mnpCustName]").attr("readonly", false);
$("input[name=prepaidSimInd]").prop("checked", false) ;
} else {
//$("input[name=prepaidSimInd]").prop("checked", false) ;
}
}).change();
You can use JavaScript substring()
function instead.
alert("abcxyz".substring(0, 3));
The JS code is evaluated when JSP have already been rendered. The alert()
function expects the argument of type string that could be printed in the dialog, but instead it is looking for variable abc
which is not available in the code. If you still want to call JSP function on the server then a better approach is to add quotes to returned value.
alert('${fn:substring("abcxyz", -1,3)}');