0

WHat am I doing worn with this code?? I am trying to create a submit popup confirmation beofre inserting record into DB and if they cancel they are returned to my index.jsp page.. I am messed with the script a few different ways but am still having issues

<form id="myform" action ="insertNew" method ="get">
<td align="right">Name: </td><td> <input type="text" name="name"></td></tr>
<tr><td><input type ="submit" onClick="formcheck()" value="Submit"></td></tr>

<script language="Javascript">

   function formcheck(){

    if (confirm("Are you sure you want to insert?"))
      {
      form.submit();
      }
    else
      {
      document.location.href = "index.jsp"
      } 
      }
        </script>


    </body>
</html>
2
Contributors
1
Reply
7
Views
5 Years
Discussion Span
Last Post by mrvijayakumar
0

Dont perform else.. Once performed, it will redirect to index.jsp. your form data will be cleared.

Remove below lines:

else
      {
      document.location.href = "index.jsp"
      } 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.