Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

this.form.submit() not working

    <form name="formUnbook" method="post" action='<%=response.encodeURL("dist-sales-order-edit.do")%>'>
                        <input type="hidden" name="formName"  value=<%=formName%>>
                        <input type="hidden" name="docTableItem" value="<%=docTableItem%>"> 
                        <input type="hidden" name="docKeyItem" value="<%=docKeyItem%>"> 
                        <%eventCalendarLinkName  = "UnBook";%>
<a class="smalllink4" href="#" onClick="fnUnbook();"><%=eventCalendarLinkName%></a>
</form>
......................................................................................
<script language="JavaScript">
        function fnUnbook(){
            answer = confirm('<%=bundle.getString("label_areYouSure")%>');
            if(answer)
            {
                this.form.submit();
            }
        }
    </script>

This.form.submit(); doesn't submit the form. Any suggestion? I also tried document.form.submit(); but doesn't worked. Where is the problem?

like image 284
Asif Avatar asked Aug 06 '26 20:08

Asif


2 Answers

change this.form.submit(); to document.getElementsByName("formUnbook")[0].submit();

like image 114
Santhosh Kumar Vijayarangan Avatar answered Aug 08 '26 09:08

Santhosh Kumar Vijayarangan


Try modifying your code like that (add id to the form):

<form name="formUnbook" id="formUnbook" method="post" action='<%=response.encodeURL("dist-sales-order-edit.do")%>'>
<!-- other stuff here -->

<script type="text/javascript">
function fnUnbook() {
  if( confirm('<%=bundle.getString("label_areYouSure")%>') ) {
    return document.getElementById('formUnbook').submit();
  }
}
</script>
like image 45
Bud Damyanov Avatar answered Aug 08 '26 10:08

Bud Damyanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!