th:onchange="javascript:showPIIDoc();"

8.3k views Asked by At

I am new to thymeleaf.

This is my select statement in thymeleaf

<select id="provider" class="form-control" th:onchange="'javascript:showPIIDoc();'">
                                                <option th:value="0" >Select a Service Provider</option>
                                                <option th:each="provider : ${user.providers}"  name="name"  th:value="${provider.id}" th:text="${provider.name}" >[name]</option>
                                            </select>

this is my javascript

   <script>
function showPIIDoc()
{
    alert('in here');
}
</script> 

After running on server i cannot see the alert. Please help me.

1

There are 1 answers

0
ndrone On

There is nothing special about your onchange attribute with the tag, that requires Thymeleaf.

Change it to

<select id="provider" class="form-control" onchange="showPIIDoc()">
     <option th:value="0" >Select a Service Provider</option>
     <option th:each="provider : ${user.providers}"  name="name"  th:value="${provider.id}" th:text="${provider.name}" >[name]</option>
</select>