php文件(a.php)
<?php
include_once("..");//smarty文件路徑echo $_POST['name_test'];
$tpl->display('a.tpl');
?>tpl文件(a.tpl)<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title><{$title}></title>
{literal}
<script language="javascript">
function test(){
var test = "test '";
alert(test);
document.getElementById("id_test").value=test;
}</script>
{/literal}
</head>
<body>
<form method="post" action="">
<input type="hidden" id="id_test" name="name_test" value="">
<input type="submit" name="sub_test" onclick="javascript:test();" value="test">
</form>
</body>
</html>不信的話,自己測試#99