【发布时间】:2013-10-14 11:56:40
【问题描述】:
我正在尝试调用resetyear 函数,它也被调用,但流程在alert("over") 处停止。它不会将控制权转移给resetmaster。
String flag = "";
flag = (String) session.getAttribute("flag");
System.out.println("flag = " + flag);
if (flag == null) {
flag = "";
}
if (flag.equals("yes")) {
%>
<script>
alert(1);
// resetyear();
dontreset();
//document.getElementById("checkyear").value = "1";
//alert(document.getElementById("checkyear").value);
</script>
<%} else if(flag.equals("no"))
{%>
<script>
alert(2);
//document.getElementById("checkyear").value = "2";
//alert(document.getElementById("checkyear").value);
resetyear();
</script>
<%}else{}%>
function resetyear(){
if(confirm("DO YOU WANT TO RESET THE YEAR?"))
{
alert("hello");
//document.forms['indexform'].action = "resetmaster";
//alert(document.forms['indexform'].action);
//document.forms['indexform'].submit();
alert("over");
form.action = "resetmaster";
form.submit();
alert(1);
}
【问题讨论】:
-
尝试将您的 html 放在 尝试对其执行操作的脚本之前。 "" 是什么意思?
-
@underscorePez 谢谢你的朋友。我更改了整个代码。我没有使用隐藏标签,而是直接从 if 条件调用该函数。我再次修改了这个问题。请检查并建议我回答
-
编辑是否使问题完全脱离了标题和答案?
标签: javascript html hidden-field