如何从PHP调用Java脚本函数 [英] How to call java script function from PHP

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

问题描述

有人可以帮助我从PHP调用Java脚本函数吗?

Can any one help me in calling java script function from PHP

<script>
function HideDiv(id)
{
  document.getElementById(id).style.display="block";				
}

</script>





if($Acidity=="Acidity")
{
        echo"Raj";	
	echo "<SCRIPT LANGUAGE='javascript'>HideDive('Acidity');</SCRIPT>";

}




我需要使Div可见.

谢谢!




I need to make the Div Visible.

Thanks!

推荐答案

Acidity == " ) { echo " ; echo " ; }
Acidity=="Acidity") { echo"Raj"; echo "<SCRIPT LANGUAGE='javascript'>HideDive('Acidity');</SCRIPT>"; }




我需要使Div可见.

谢谢!




I need to make the Div Visible.

Thanks!


Rajesh,

由于属性lang等于php的pre标签似乎对双引号进行了一些不必要的修改,因此我将用lang等于text张贴我的答案(不是很好地格式化,但是您所读的是我写的:)):

Hi Rajesh,

since the pre tag with attribute lang equal to php seems to make some unwanted modifications concerning double quotes I''ll post my answer with lang equal to text (not so nicely fomatted but what you read is what I wrote :) ):

<script type="text/javascript">
function HideDiv(id)
{
    document.getElementById(id).style.display="block";
}
</script>





if(


Acidity =="Acidity") { 回声"Raj"; echo< script type ='text/javascript'> HideDiv('Acidity');</script>" ;; }
Acidity=="Acidity") { echo "Raj"; echo "<script type='text/javascript'>HideDiv('Acidity');</script>"; }



我在您的代码中发现了两个问题:
1.用于选择脚本语言的脚本标签的属性称为type
并以文本/javascript"作为JavaScript代码.
2.您编写的函数名为HideDiv(id),您称为函数HideDive(id).


希望您能将其与这些更正一起使用!


最好的问候,


曼弗雷德

PS:如果该函数的语义是显示div而不是隐藏div,则应将其称为ShowDiv.



There are two issues I found in your code:
1. Script tag''s attribute to select scripting lanuage is called type
and takes "text/javascript" for javascript code.
2. Function you wrote is named HideDiv(id) you called a function called HideDive(id).


I hope you get it to work with these corrections!


Best Regards,


Manfred

PS: The function should be called ShowDiv if its semantic is to reveal the div and not to hide it.


这篇关于如何从PHP调用Java脚本函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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