I am using "Thymeleaf", I want to send the value to javascript, I am new to this, I am trying below code:
onclick="getPropId('${properties.id}')"
and function
getPropId(inputID){alert(inputId);}
But I am not getting actual value.
Above issue is resolved now, we need to use Thymeleaf specific syntax.
th:onclick="'getPropId(\'' + ${properties.id} + '\');'"
Now if its displying proper properties.id in javascript function.
function getPropId(inputID){
alert(inputID);
}
For passing multiple parameters, you can use the following:
th:onclick="'doSomething(\''+${val1}+ '\',\''+${val2}+'\',\''+${val3}+'\');'"
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