php和javascript之间变量的传递实现代码

前端之家收集整理的这篇文章主要介绍了php和javascript之间变量的传递实现代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PHP variable to Javascript variable:
<div class="codetitle"><a style="CURSOR: pointer" data="7197" class="copybut" id="copybut7197" onclick="doCopy('code7197')"> 代码如下:

<div class="codebody" id="code7197">
<?php $myvar=10; ?>
<script type="text/javascript">
jsvar = <?php echo $myvar; ?>;
document.write(jsvar); // Test to see if its prints 10:


Form variable to Javascript variable:
<div class="codetitle"><a style="CURSOR: pointer" data="98911" class="copybut" id="copybut98911" onclick="doCopy('code98911')"> 代码如下:
<div class="codebody" id="code98911">
<form name="myform4">
<input type="hidden" name="formvar" value="100">

<script type="text/javascript">
jsvar = document.myform4.formvar.value;
document.write(jsvar) // test


PHP variable to Form variable:
<div class="codetitle"><a style="CURSOR: pointer" data="76884" class="copybut" id="copybut76884" onclick="doCopy('code76884')"> 代码如下:
<div class="codebody" id="code76884">
<form name="myform4">
<input type="hidden" name="formvar" value="<?php $phpvar=10; echo $phpvar; ?>"> // PHP code inside HTML!!


Javascript variable to Form variable:
<div class="codetitle"><a style="CURSOR: pointer" data="16405" class="copybut" id="copybut16405" onclick="doCopy('code16405')"> 代码如下:
<div class="codebody" id="code16405">
<form name="myform3">

<input type="hidden" name="formvar" value="">

<script type="text/javascript">
jsvar=10;
document.myform3.formvar.value = jsvar;

原文链接:https://www.f2er.com/php/26845.html
php变量变量传递

猜你在找的PHP相关文章