dongxinjun3944 2013-12-09 07:13
浏览 98
已采纳

在PHP中创建和调用JavaScript函数

I have just started learning how to create web applications in PHP after migrating from ASP.NET.

I wanted to know how to integrate JavaScript with PHP. For example, there is a Home.php page that resides in the website's root folder. The page has an HTML button on it and a simple JavaScript function that contains code for a pop-up window that says, "Hello!" I want to call this function at the click event of this HTML button. Can anyone please help me? I know how this can be achieved in ASP.NET. I want to know how it can be done in PHP. After getting the solution to this problem, I will learn move to AJAX and then jQuery.

I am not aware whether a similar question like this has been posted on this forum before. If it has then the mods can take a call and delete this post and send me a PM containing the link to the similar question. :D

Thank you in advance.


Thank you all very much for your replies. :)

The solution that you have given me is in HTML; but how do I achieve this in PHP?

  • 写回答

3条回答 默认 最新

  • douzhicai7148 2013-12-09 07:20
    关注
    <script>
    
    function myFunction() {
      alert("Clicked");
    }
    
    </script>
    
    <button onclick="myFunction()">Click me</button>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!