Hello
I wonder if somebody knows how to solve the next:
I want to send a value from the template to a script and it seems it works but I get an error: Uncaught TypeError: Cannot read property 'value' of null
Below it is my code:
Template:<input type="hidden" id="idobra" name="variable" value="{{ obra.id }}">
{{ obra.id }} is an object sended from views.py
Javascript:var idobra = document.getElementById("idobra").value;
console.log(idobra);
And I don't know what I'm doing wrong. I would like to know if there is another way to send objects directly from django to javascript or if I'm doing well like that, but
solving the problem.
Thank you very much!