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
更多推荐
发布评论