I want to pass multiple parameters on onClick in From Thymeleaf to javascript function.
<label th:onclick="getUserId(userId,email);" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">
My Javascript function is:-
<script>
function getUserId(userID,userEmail){
console.log(userID,userEmail);
}
</script>
How to do it?
It can be done by using the following:-
<label th:onclick="getUserId([[${userId}]],[[${email}]] );" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">
Here, userId is of Integer type end email is of String type.
Update :-
This also works:-
<label th:data-parameter1="${userId}" th:data-parameter2="${email}" th:onclick="getUserId(this.getAttribute('data-parameter1'),this.getAttribute('data-parameter2'));" for="radio-11" data-toggle="tooltip" data-placement="bottom" data-trigger="hover" class="pm-tab1-pad">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With