admin管理员组

文章数量:1293448

i try to use confirm box but it does not work after 'OK' pressing this is my confirm box

<script language="JavaScript">
{literal}
function confirmBox()
{
 var where_to= confirm("Silmek istediğinizden emin misiniz?");
 if (where_to== true)
     return true;
 else{
     alert("Silme işleminden vazgeçtiniz yönlendiriliyorsunuz");
     return false;
 }
}
{/literal}
</script>



 <form name="removeFortune" method="post" action="#">
    <table border="0" name="tableArticle">
     {foreach from=$articles value=article}
        <tr>
            <td><input type="checkbox" name="checkArticle[]" value="{$article.id}" /></td>
            <td>{$article.title}</td>
        </tr>
        {/foreach}
    </table>
    <input type="submit" onclick="confirmBox()" name="removeArticle" value="Sil" />
    <br /><br />

    {$deleteMessage}

</form>

i try to use confirm box but it does not work after 'OK' pressing this is my confirm box

<script language="JavaScript">
{literal}
function confirmBox()
{
 var where_to= confirm("Silmek istediğinizden emin misiniz?");
 if (where_to== true)
     return true;
 else{
     alert("Silme işleminden vazgeçtiniz yönlendiriliyorsunuz");
     return false;
 }
}
{/literal}
</script>



 <form name="removeFortune" method="post" action="#">
    <table border="0" name="tableArticle">
     {foreach from=$articles value=article}
        <tr>
            <td><input type="checkbox" name="checkArticle[]" value="{$article.id}" /></td>
            <td>{$article.title}</td>
        </tr>
        {/foreach}
    </table>
    <input type="submit" onclick="confirmBox()" name="removeArticle" value="Sil" />
    <br /><br />

    {$deleteMessage}

</form>
Share Improve this question edited May 8, 2012 at 12:19 hakre 198k55 gold badges447 silver badges854 bronze badges asked May 8, 2012 at 12:13 snnlankrdsmsnnlankrdsm 1,4015 gold badges19 silver badges29 bronze badges 2
  • When user clicks on " OK ", it will e in if condition. you have written return true .. it will es out of JS function... what else you expect? – Rukmi Patel Commented May 8, 2012 at 12:18
  • homework :D i dont think so – snnlankrdsm Commented May 8, 2012 at 12:23
Add a ment  | 

1 Answer 1

Reset to default 10

If you want it to submit after pressing OK, you need to change 1 simple thing. Add a return

onclick="return confirmBox()"

Although I would say:

onsubmit="return confirmBox()"

本文标签: Javascript confirm boxStack Overflow