使用<a> tag after confirm

时间:2017-12-11 04:39:40

标签: javascript jquery html

I am trying to submit a form through a tag. I have tried triggering document.myform.submit(), this.form.submit(), parentNode.submit() etc. but none of this is working! Using a submit button or remove confirm() the code works fine. But I want to use both of them. Need some help.

<form method="post" onsubmit="return confirmm('Delete this record?');">
    <a href="" class="deleteThisRecord" type="submit" onclick="$(this).closest('form').submit();" name="delete">
        Delete This Record
    </a>
    <input type="hidden" name="id" value="<{$listData[I]['id']}>">
</form>


function confirmm($confirmText = 'Delete?') {
    var dicision = confirm($confirmText);
    if (dicision) {
        return true;
    } else {
        return false;
    }
    return false;
}

1 个答案:

答案 0 :(得分:-1)

为表单提供id属性,并将submite调用到此id引用文档getById(&#39; yourIdName&#39;)。submit();