1.PHP a.PHP -> HTML & JavaScript html 代码中 <input type="" readonly="readonly" style='background-color:#DCDCDC' value=<?php echo $perinfo[ID];?> /> JavaScript 代码中 代码如下: <script type="text/javascript"> var ability=<?php echo JSON($array);?>; </script> b.PHP <-> MySQL php 代码中 代码如下: <?php $dbcnx = @mysql_connect ( "localhost", "root", "1234" ); if (! $dbcnx) { echo ("Unable to connect to the " . "database server at this time."); exit (); } if (! @mysql_select_db ( "pms" )) { echo ("Unable to locate the joke " . "database at this time."); exit (); } mysql_query ( "SET NAMES 'GB2312'" );
$q=mysql_query("select * from ability where ALV = 1"); while($row=mysql_fetch_array($q)){ $array1[] = $row[AName]; } ?> 2.HTML a. HTML -> PHP (POST 方式) html 代码中 代码如下:
<form id="form" name="form" method="POST" action="do.php"> <input type="hidden" id="count" name="count" value="1"/> <input type="submit" name="Submit" value="Search"/> </form> do.php 文件代码中 代码如下: <?php echo $_POST['count']; ?> b. HTML -> JavaScript
JavaScript 代码中 (可获得,可更改) 代码如下: <script type="text/javascript"> var te = document.getElementById("count"); te.value = 1; </script> 3.JavaScript a. JavaScript -> HTML (通用法, 未验证) JavaScript 代码中 代码如下: <script type="text/javascript"> function f(){ var id = "2"; var a = document.getElementById("a"); a.href.replace("(n)", id); } </script>
html 代码 代码如下: <a id="a" href="ExportArticle.action?articles=(n)"/> b. JavaScript -> PHP 通过 html 的转接
1.JavaScript 代码先给 html 代码如下: <script type="text/javascript"> var i = 1; var te = document.getElementById("count"); te.value = i; </script> 2.html 代码给 php 代码如下: <form id="form" name="form" method="POST" action="do.php"> <input type="hidden" id="count" name="count" value="1"/> <input type="submit" name="Submit" value="Search"/> </form> 3.do.php 接收到 代码如下: <?php echo $_POST['count']; ?>
--转自