作者MamaMe (ooh)
看板PHP
標題Re: [請益] 要如何傳值給JavaScript
時間Fri Mar 13 05:01:14 2009
※ 引述《woeijou ( =資三連線= wei)》之銘言:
: 請問一下
: 在同一頁的話
: PHP要如何將傳變數給JavaScript
sorry i can only type in english.
my question is quite the same to the previous one so that i post it here.
would somebody tell me why my program can not disply the value 100 and
even the "Hello" string?
I am also trying to pass a variable from PHP to javascript in the same page
(the same file xxx.htm).
really appreciate any response!
<html>
<head>
<?php $myvar = 100;?>
<script language="javascript" type="text/javascript">
function Check()
{
document.write("Hello");
jsVar = <?php echo $myvar;?>;
document.write(jsVar);
}
</script>
</head>
<body>
<input type="submit" value="send" onclick="Check();"/>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 128.2.238.94
→ LPH66 :xxx.htm...該不會你是存成.htm吧?! 03/13 09:42
→ LPH66 :PHP程式要存成 .php 伺服器才會知道... 03/13 09:42
推 flamerecca :阿阿 有種被搶怪的感覺... 03/13 09:44