0

It works for Firefox and Chrome though Not very sure what is the reason. Using jsp in apache tomcat.

form code is as below

<form id="form1" method="POST" action="zzz.jsp?yy=submit">
    <input type="button" name="submit" id="submit" value="Submit" onclick="Submitconfirm()" />
    </p>
</form>

javascript of Submitconfirm

function Submitconfirm() {
    var a = document.getElementById("form1");

    if (confirm()) {
        a.submit();
    }
}

function confirm() {
    return confirm('Are you sure these details are correct?');
}

jsp does not have postback function so I had to resort to this,on submit will execute javascript to send the form.

nickdos
  • 8,348
  • 5
  • 30
  • 47
user1663380
  • 1,003
  • 4
  • 18
  • 21
  • updated the function, I get a Internet Explorer cannot display the webpage error everytime I run on IE 9 – user1663380 Nov 07 '12 at 16:32
  • not very sure it has something to do with this issue:http://stackoverflow.com/questions/7577542/ie9-double-form-submit-issue – user1663380 Nov 07 '12 at 16:45
  • You have a `` tag in the form that is not balanced. – nickdos Nov 08 '12 at 00:33
  • I don't think it is related to that SO question - it had a `type="submit"` on the same element that had the `onClick`. Your button is `type="button"` so it should not submit the form on its own. – nickdos Nov 08 '12 at 00:36

1 Answers1

0

You have to rename your button to something else as its causing a clash with the JS .submit() function. See this SO question for more details. E.g.

<input type="button" name="submitButton" id="submit" value="Submit" onclick="Submitconfirm()" />
Community
  • 1
  • 1
nickdos
  • 8,348
  • 5
  • 30
  • 47