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>

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"
      } 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.