Reputation: 309
<form:select multiple="false" id="zoneIds" path="id" >
<form:option value="0" selected="selected" label="Non" />
<c:forEach items="${zones}" var="zone">
<form:option value="${zone.id}" label="${zone.zoneId}" test1="${zone.allowIparkBarcode}" />
</c:forEach>
</form:select>
I wanna get the test1 value in Javascript, I have tried the below but never worked:
$(document).ready(function(){
$("#zoneIds").on("change", function(){
const dc = $("#zoneIds").val( $(this).attr("test1") );
console.log("TEST " + dc)
if(dc === "true"){
$("#lpr").hide();
$("#scanTicket").show();
}else{
$("#scanTicket").hide();
$("#lpr").show();
}
});
});
Thanks for the help
Upvotes: 0
Views: 31
Reputation: 309
For people coming across this Q I was able to solve it by:
var dc = $('option:selected', this).attr('test1');
Instead of:
const dc = $("#zoneIds").val( $(this).attr("test1") );
Upvotes: 1