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();
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742417306a4439990.html
评论列表(0条)