Reputation: 149
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?
Upvotes: 2
Views: 5077
Reputation: 149
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">
Upvotes: 9