Re: [請益] 要如何傳值給JavaScript

看板PHP作者 (ooh)時間16年前 (2009/03/13 05:01), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《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

03/13 09:42, , 1F
xxx.htm...該不會你是存成.htm吧?!
03/13 09:42, 1F

03/13 09:42, , 2F
PHP程式要存成 .php 伺服器才會知道...
03/13 09:42, 2F

03/13 09:44, , 3F
阿阿 有種被搶怪的感覺...
03/13 09:44, 3F
文章代碼(AID): #19kNWRO2 (PHP)
討論串 (同標題文章)
文章代碼(AID): #19kNWRO2 (PHP)