如何在PHP中使用javascript? [英] How to use javascript in php?

查看:83
本文介绍了如何在PHP中使用javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何在php中使用javascript?

我想将一些值返回给php。

谢谢


-

来自Realss的尚文斌

Hi,

How to use javascript in php?
I want to return some values to php.
Thanks

--
Shang Wenbin from Realss

推荐答案

尚文斌写道2005年4月25日在comp.lang.javascript
Shang Wenbin wrote on 25 apr 2005 in comp.lang.javascript:



嗨太多

如何在PHP中使用javascript?


你不能。 PHP不支持JS。

但是,...

我想将一些值返回给php。
Hi,
Hi too
How to use javascript in php?
You cannot. PHP does not support JS.
However, ...
I want to return some values to php.




如果你问如何发送clientide javascript值

到服务器端[PHP,...]:


< form id = f方法= post>

< input type = hidden name = JSvalue id = h>

< / form>


。 ....


document.getElementById(''h'')。value =" Hello"

document.getElementById(''f'' ).submit()


-

Evertjan。

荷兰。

(替换所有在我的电子邮件地址中都带点圆点)



if you are asking how to send a clientside javascript value
to serverside [PHP, ... ]:

<form id=f method=post>
<input type=hidden name=JSvalue id=h>
</form>

.....

document.getElementById(''h'').value="Hello"
document.getElementById(''f'').submit()

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


你需要将他的javascript嵌入到你的php中。


例如


echo"< html>< body>< head>" ;;

echo"< script LANGUAGE = \" ; JavaScript1.4\" type = \" text / javascript \"">;

echo" function sayHello(){" ;;

echo" alert( \" hello \");" ;;

echo"< / script>< / head>< / body>< / html>" ;;

You need to embed the he javascript into your php.

e.g.

echo "<html><body><head>";
echo "<script LANGUAGE=\"JavaScript1.4\" type=\"text/javascript\"">;
echo "function sayHello(){";
echo "alert(\"hello\");";
echo "</script></head></body></html>";


或者您也许可以在客户端Javascript中收集结果,并通过刷新页面并传递

将值传回PHP结果为

部分Querystring?


干杯,Ash


< cl **** *@eircom.net>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
Or you could perhaps gather your results in clientside Javascript, and pass
the values back to the PHP by refreshing the page and passing the results as
part of the Querystring?

Cheers, Ash

<cl*****@eircom.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
你需要将他的javascript嵌入到你的php中。

回声"< html>< body>< head>" ;;
echo"< script LANGUAGE = \" JavaScript1.4 \" type = \" text / javascript \"">;
echo" function sayHello(){" ;;
echo" alert(\" hello \" ;);" ;;
echo"< / script>< / head>< / body>< / html>" ;;
You need to embed the he javascript into your php.

e.g.

echo "<html><body><head>";
echo "<script LANGUAGE=\"JavaScript1.4\" type=\"text/javascript\"">;
echo "function sayHello(){";
echo "alert(\"hello\");";
echo "</script></head></body></html>";



这篇关于如何在PHP中使用javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆