javascript onsubmit没有解雇(javascript onsubmit not firing)

编程入门 行业动态 更新时间:2024-10-28 07:18:56
javascript onsubmit没有解雇(javascript onsubmit not firing)

我有一个不会开火的功能,我不能为我的生活找出原因。 希望有人能看到我所缺少的东西......

在页眉中

<script type="text/javascript"> <!-- function confTakeIt(asdate,astime,aetime) { var ans = confirm("Are you sure you want to signup for this OT?\n\n" + asdate + " " + $astime + " to " + $aetime); if (ans) { return true; } else { return false; } } //--> </script>

调用上述功能的页面上的几种不同形式

<form method="post" name="takeIT" id="takeIT" action="takeOT.php" onsubmit="return confTakeIt('Sat 05-30-15','1530','0400')"><input type=hidden name="sumsg"><input type=hidden name="action" value="Add"><input type=hidden name="otid" value="61"><input type="image" src="/images/signup-sign.png" width=70 border=0 alt="Sign Up" value="submit"></form> <form method="post" name="takeIT" id="takeIT" action="takeOT.php" onsubmit="return confTakeIt('Wed 06-03-15','1800','0630')"><input type=hidden name="sumsg"><input type=hidden name="action" value="Add"><input type=hidden name="otid" value="63"><input type="image" src="/images/signup-sign.png" width=70 border=0 alt="Sign Up" value="submit"></form>

I have a function that will not fire and I can't for the life of me figure out why. Hopefully someone can see what I'm missing...

in the page header

<script type="text/javascript"> <!-- function confTakeIt(asdate,astime,aetime) { var ans = confirm("Are you sure you want to signup for this OT?\n\n" + asdate + " " + $astime + " to " + $aetime); if (ans) { return true; } else { return false; } } //--> </script>

several different forms on the page calling the above function

<form method="post" name="takeIT" id="takeIT" action="takeOT.php" onsubmit="return confTakeIt('Sat 05-30-15','1530','0400')"><input type=hidden name="sumsg"><input type=hidden name="action" value="Add"><input type=hidden name="otid" value="61"><input type="image" src="/images/signup-sign.png" width=70 border=0 alt="Sign Up" value="submit"></form> <form method="post" name="takeIT" id="takeIT" action="takeOT.php" onsubmit="return confTakeIt('Wed 06-03-15','1800','0630')"><input type=hidden name="sumsg"><input type=hidden name="action" value="Add"><input type=hidden name="otid" value="63"><input type="image" src="/images/signup-sign.png" width=70 border=0 alt="Sign Up" value="submit"></form>

最满意答案

您使用了错误的变量名称

function confTakeIt(asdate, astime, aetime) { //variable names are astime and aetime not $astime and $aetime var ans = confirm("Are you sure you want to signup for this OT?\n\n" + asdate + " " + astime + " to " + aetime); if (ans) { return true; } else { return false; } }

演示: 小提琴

You have used wrong variable names

function confTakeIt(asdate, astime, aetime) { //variable names are astime and aetime not $astime and $aetime var ans = confirm("Are you sure you want to signup for this OT?\n\n" + asdate + " " + astime + " to " + aetime); if (ans) { return true; } else { return false; } }

Demo: Fiddle

更多推荐

本文发布于:2023-08-06 18:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1453903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:javascript   onsubmit   firing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!