Home > Backend Development > PHP Tutorial > javascript-How to implement click execution of js function with parameters in php

javascript-How to implement click execution of js function with parameters in php

WBOY
Release: 2023-03-01 13:46:02
Original
1005 people have browsed it

javascriptphp

<code> echo "             <tr>              <td><button onclick=\"check(".$user['brandname'].")\">".$user['brandname']."</button></td>             </tr>          ";                    这是我的代码,发现点击后没反应,是为什么。。。。。                    js部分                    function check(a){    alert(a);}</code>
Copy after login

Reply content:

String parameters should be enclosed in quotes

<code> echo "
             <tr>
              <td><button onclick=\"check('".$user['brandname']."')\">".$user['brandname']."</button></td>
             </tr>
          ";
</code>
Copy after login
<code> 你这传给js的值不是一个字符串,解决方法同楼上。
</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template