admin管理员组文章数量:1336660
Hi I've the following code in jsp. I am trying to pass the value to javascript as follows. But it is not working.The code is as follows:
<td><button name = "btn" onclick="callMe(<c:out value='${bus.vehicleId}'/>")>Show Details</button></td>
(Vehicle id is printing if I use in my jsp.) Javascript is like this.
function callMe(myId) {
alert(myId);}
Here I am getting value as "undefined". I've tried in different way as follows
<td><button name = "btn" onclick="callMe('${bus.vehicleId}')>Show tails</button></td>
This is also not working.Please help me asap.
Hi I've the following code in jsp. I am trying to pass the value to javascript as follows. But it is not working.The code is as follows:
<td><button name = "btn" onclick="callMe(<c:out value='${bus.vehicleId}'/>")>Show Details</button></td>
(Vehicle id is printing if I use in my jsp.) Javascript is like this.
function callMe(myId) {
alert(myId);}
Here I am getting value as "undefined". I've tried in different way as follows
<td><button name = "btn" onclick="callMe('${bus.vehicleId}')>Show tails</button></td>
This is also not working.Please help me asap.
Share Improve this question edited Aug 2, 2013 at 10:45 user2028750 asked Aug 2, 2013 at 10:24 SrinivasSrinivas 1553 gold badges3 silver badges10 bronze badges 1-
Debug what you actually have in
${bus.vehicleId}
. – Alex Commented Aug 2, 2013 at 12:36
2 Answers
Reset to default 2Your vehicleID might be string. If so, Yes! you get always undefined as a result. What ever the values ing as a result of <c:out value='${bus.vehicleId}'/>
will be treated as a variable in html and javascript trying to print that variable value, which is undefined
.
Try this way to let java script treat that jstl value as string literal
onclick="callMe('${bus.vehicleId}')">
Find single colon and double colons positions!
<tr class="txtnbmed">
<td align="center"><c:out value="${conPartRef.opCode}" /></td>
<td align="center"><html:select property="approvalStatus" indexed="true" name="conPartRef">
<option value="" <c:if test="${conPartRef.approvalStatus==''}">selected</c:if>>--- SELECT ---
<option value="A" <c:if test="${conPartRef.approvalStatus=='A'}">selected</c:if> >Approved
<option value="R" <c:if test="${conPartRef.approvalStatus=='R'}">selected</c:if> >Rejected
</option>
</html:select>
</td>
</c:forEach>
<input type="button" class="txtMF" value="Confirm & Print Supplement RO" onclick="doMarkAsOFP(this.form)">
function doMarkAsOFP(form) {
// need to get approvalStatus values and the opCode values.
submitPage();
}
本文标签: jsppassing jstl value to javascriptStack Overflow
版权声明:本文标题:jsp - passing jstl value to javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742417306a2470964.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论