0
<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

1

1 Answer 1

1

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") );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.