vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to make a php variable work inside a javascript function? (https://vborg.vbsupport.ru/showthread.php?t=54678)

EvilLS1 06-24-2003 09:37 AM

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?

filburt1 06-24-2003 10:36 AM

As Javascript is a client side language and PHP is a server-side language, you can't.

EvilLS1 06-24-2003 08:09 PM

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.

noppid 06-26-2003 02:56 PM

In a file...
Change the filename to whatever.php and try...
Code:

<input name="r1" type="radio" value="" onClick="toggleT('<? echo $phpvariable ?>','s')">
In the postbit template try this...
Setup the var in the showthread.php before the postbit EVAL...
Code:

$post[JavaVarToPass]=$phpvariable;
Then in post bit...
Code:

<input name="r1" type="radio" value="" onClick="toggleT('$post[JavaVarToPass]','s')">

DeMuro1 07-01-2003 07:55 AM

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

EvilLS1 07-01-2003 07:59 AM

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
  • Page Generation 0.00999 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete