we usually put the echo or print line in the value of a "hidden" text box.
-
-
<input type="hidden" name="someVar" id="someVar" value="<?php echo $myVar; ?>" />
-
-
and then you can reach it via javascript once the page has been written (remember javascript = runs on client computer, PHP executes on the server before its delivered to the client computer)
So the browser sees the page as
[HTML]
<input type="hidden" name="someVar" id="someVar" value="YOUR_MY_VAR_VALUE_HERE" />
[/HTML]
and now JavaScript can access it this way:
-
alert("Value is " + document.getElementById("someVar").value);
-
-
If you're printing this value elsewhere on the page, put inside a tag and give that tag an id for example:
-
-
<div id="container">
-
<span id="someVal"><?php echo $myVal; ?></span>
-
</div>
-
-
and you can access that with the attribute "innerHTML" such as
-
-
alert("Value is " + document.getElementById("someVar").innerHTML);
-
-
if you STILL don't get it, Google: "miracle".
Dan