![]() |
How to make a php variable work inside a javascript function?
Say I have something like this:
<script type=text/javascript> blah blah blah </script> <form> <input name="r1" type="radio" value="" onClick="toggleT('$phpvariable','s')"> </form> How can I make the $phpvariable work with the onClick function? |
As Javascript is a client side language and PHP is a server-side language, you can't.
|
Ah, well that puts a damper on things. I thought maybe there was some kinda trick that I didn't know. Thanks for the reply.
Anyone here good with javascript? I plan on placing this form in the postbit and since it will be displayed several times per page I need a different number or word in each post to show up where $phpvariable is (so that all forms work independently).. Originally I had planned to use the postid since it would be different for every post, but now I'll have to figure out another way to do it. Does anyone know of a javascript function that can do this? Any help would be appreciated. |
In a file...
Change the filename to whatever.php and try... Code:
<input name="r1" type="radio" value="" onClick="toggleT('<? echo $phpvariable ?>','s')"> Setup the var in the showthread.php before the postbit EVAL... Code:
$post[JavaVarToPass]=$phpvariable; Code:
<input name="r1" type="radio" value="" onClick="toggleT('$post[JavaVarToPass]','s')"> |
you'd need to code the javascript to output some text.
javascript: If (some condition met) { echo(<? $phpvariable >) } else { echo(<? $some_other_phpvariable >) } etc etc that's how I'd do it |
Thanks for the input guys, but I've already solved the problem. :)
Check this thread for details: https://vborg.vbsupport.ru/showthrea...threadid=54709 |
All times are GMT. The time now is 08:31 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|