The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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? |
#2
|
|||
|
|||
As Javascript is a client side language and PHP is a server-side language, you can't.
|
#3
|
||||
|
||||
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. |
#4
|
|||
|
|||
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')"> |
#5
|
||||
|
||||
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 |
#6
|
||||
|
||||
Thanks for the input guys, but I've already solved the problem.
Check this thread for details: https://vborg.vbsupport.ru/showthrea...threadid=54709 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|