本文介绍了如何通过javascript设置输入隐藏字段的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调用resetyear函数,并且它也被调用,但是流程停止在alert(over),它不会将其控制转移到resetmaster。请给我一些建议。

I am trying to call the resetyear function and its getting called also but the flow stops at alert("over"), it doesnt tranfer its control to resetmaster. Please suggest me something.

    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);
}


推荐答案

/ p>

For me it works:

document.getElementById("checkyear").value = "1";
alert(document.getElementById("checkyear").value);

也许你的JS没有执行,你需要在它周围添加一个函数(){}。

Maybe your JS is not executed and you need to add a function() {} around it all.

这篇关于如何通过javascript设置输入隐藏字段的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:47