Javascript 如何在php中创建onclick div
上面的代码是我的javascript代码Javascript 如何在php中创建onclick div,javascript,php,html,Javascript,Php,Html,上面的代码是我的javascript代码 <script type="text/javascript"> function Invest() { alert("Mechanical /n Electrical /n Computer /n Civil"); } function create() { alert("Graphic /n Interior /n Architecture"); } function motivate() { alert("Busi
<script type="text/javascript">
function Invest()
{
alert("Mechanical /n Electrical /n Computer /n Civil");
}
function create()
{
alert("Graphic /n Interior /n Architecture");
}
function motivate()
{
alert("Business Administration /n Accounting and Finance");
}
</script>
我想做的是将echo更改为divonclick,这样它将从javascript调用我的函数,并显示其中的信息
像这样的
<form action="main.html" method="post">
<?php
$v2 = $_GET['dropdown'];
if ($v2=="investigative" )
{
echo "<h3>It's recommended that you follow</h3><h2>Engineering School</h2>";
}
else if ($v2=="creative" )
echo "<h3>It's recommended that you follow</h3><h2>Arts School</h2>";
else if ($v2=="motivated" )
echo "<h3>It's recommended that you follow</h3><h2>Business School</h2>";
?>
当我这么做的时候,我觉得我犯了一个错误
分析错误:语法错误,意外的“onclick”T_字符串,应为“,”或“;”在第35行的C:\xampp\htdocs\MyProject\eval.php中
我做错了什么?如何让它工作?我是新来php的:/不是像这样的回音,接近800,正在计数。开发人员喜欢错误消息,因为谷歌搜索几乎总能找到答案。此外,养成用谷歌搜索错误消息的习惯。相信我,以前有成千上万的人问过这个问题,你自己想出来并不困难。现在它终于起作用了!非常感谢。我现在只需要改变我的警惕,我相信它会好起来的:非常感谢@Antreas如果你别忘了读,我宁愿做echo’…”;为了保持一致,我在HTML中使用了双引号。@MKhalidJunaid他在这里9个月了,有7个问题,净票数为-4,对其他内容只投了两次票,并接受了一个答案。不要对一个人期望太高。更好的是,不要鼓励它。@MikeB现在我在读了《吸血鬼问题》后意识到,我投票决定结束
echo ""<div onclick=Invest();"<h3>It's recommended that you follow</h3><h2>Engineering School</h2>";
echo "<div onclick='Invest()'><h3>It's recommended that you follow</h3><h2>Engineering School</h2></div>";