I wasn't sure if this would be more appropriate here or in the client-side help forum but here goes. :)
I'm a newbie when it comes to web development and I'm trying to figure out why this doesn't work...
My code basically looks something like this:
$value = "text";
echo "<button onclick='myFunction($value)'>Click me</button>
element = document.getElementById(parameter);
element.style.color = 'blue';
<p id="text">Change me</p>
So, basically I want to press the button and make the text change color. It doesn't work however.
Observations I have made:
1. The function myFunction is called when clicking the button.
2. It works if I change "parameter" to "text" in the function, so it looks like "element = document.getElementById("text")".
It seems to me that there is something funky going on when I use the $value variable as parameter for the function in the echo. It just doesn't seem to get the correct string.