I want to pass JSTL from my onclick event to javascript. My onclick looks like this,
onclick="cancelButtonAction(<c:out value='${loop.index}'/>, <c:out value="${iList.inStr}"/>);"
and my cancelButtonAction function is,
function cancelButtonAction(index, inSchLdTsStr){
document.getElementById('loadDate'+index).value = inSchLdTsStr;
}
But this wouldnt work. Onclick the event is not getting triggered. Any suggestions?
I want to pass JSTL from my onclick event to javascript. My onclick looks like this,
onclick="cancelButtonAction(<c:out value='${loop.index}'/>, <c:out value="${iList.inStr}"/>);"
and my cancelButtonAction function is,
function cancelButtonAction(index, inSchLdTsStr){
document.getElementById('loadDate'+index).value = inSchLdTsStr;
}
But this wouldnt work. Onclick the event is not getting triggered. Any suggestions?
Share Improve this question asked Jun 7, 2013 at 20:28 GeekGeek 3,32916 gold badges79 silver badges122 bronze badges 1- Do you see any JS error in console ? – NullPointerException Commented Jun 7, 2013 at 20:36
2 Answers
Reset to default 5If it is a string you need to add the '
or "
for the parameter, look the code below:
onclick="cancelButtonAction(<c:out value='${loop.index}'/>, '<c:out value="${iList.inStr}"/>);'"
Your string is terminated in between
use like this.
onclick="cancelButtonAction(<c:out value='${loop.index}'/>, <c:out value='${iList.inStr}'/>);"