On Jan 23, 4:16 pm, David Dorward <dorw...@yahoo.comwrote:
Quote:
Jeremy Felt wrote:
Quote:
It doesn't work at all and IE gives an error stating that $variable is
undefined.
$variable is given a value right before the onclick statement with PHPPHP runs on the server and generates some data which the server sends to the
client.
>
JavaScript runs on the client.
>
A variable in PHP won't magically appear in JavaScript. You have to have PHP
generate some JavaScript which creates the variable.
>
--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Right. I think I have that part, but maybe not. I wrote the previous
message too quickly because I was on my way out the door.
I am using PHP for the database stuff and "echo"ing it out as
html/javascript. The real statement in question is along the lines of:
------------------------
$variable=12345;
echo '<span style="underlined text blah blah"
onclick="myFunction($variable)">text</span>'; // doesn't work
-----------------------
vs.
----------------------
echo '<span style="underlined text blah blah"
onclick="myFunction(12345)">text</span>'; // works
-----------------------
A global.js file that defines myFunction is being called earlier in the
code with another echo statement. This part seems to be working
because I can replace $variable with 12345 and have it work.
My admittedly weak understanding is that PHP would pass the value of
$variable to the HTML/JS stuff when it was outputted on the client side
just like any other PHP page working with variables and that Javascript
would never see the $variable portion, just 12345.
Does that change anything/make any sense?
Thanks!