I have a page with several div's. All of the divs have a unique id. I would like to send that id to a javascript function. I have tried to save it as a value as well, and send this.value, but that does not work either.
<div class='recordElem$val' id='$rname' value='$rname'
onclick='javascript:updateRecord(this.value);'>
$name</div>"
You can assign php variables value to javascript variable value. Then you can use it onclick example:
Here we can pass javascript's variable to function.
Use
onclick="updateRecord(this)"
and handle it like this:Here is a jQuery answer
Have a look at two ways to solve this problem
How about passing this.id to the javascript function?