在javascript中运行循环以确认警报?

时间:2013-07-10 07:24:07

标签: php javascript jquery html

这是我的代码

<script type="text/javascript">
    function validate()
    {
        var con=confirm("Are You Want to add More Packages");
        if(con==true)
        {
            var radio1=document.getElementById('first_radio');
            if(radio1.checked==true)
            {

                var a=document.getElementById('total').value;
                b=(parseInt(a)+parseInt(a));
                document.getElementById('total').value=b;
                var c=confirm("Are You Want to add More Packages")
                if(c==true)
                {

                }
            }
        }
        else
        {
            alert("you clicked Cancel");
        }  
    }
</script>

在此代码中,我想在用户点击取消确认警报时运行该添加。有人帮忙吗?谢谢提前..

1 个答案:

答案 0 :(得分:0)

试试这个,

<script type="text/javascript">
    function validate()
    {
        var con=confirm("Are You Want to add More Packages");
        if(con==true)
        {
            var radio1=document.getElementById('first_radio');
            if(radio1.checked==true)
            {
                var a=document.getElementById('total').value;
                b=(parseInt(a)+parseInt(a));
                document.getElementById('total').value=b;
                validate();// call this function again from here
            }
        }
        else
        {
            alert("you clicked Cancel");
        }  
    }
</script>