title: Confirmation box appears twice
body: <p>I have a confirmation box in javascript. The confirmation box works but there is a slight glitch. When the confirm box apears, if I click OK or cancel, the box will close and open again asking for a second time to confirm, if I click Ok or cancel for the box the second time, then it would submit the form. Why is it display the confirmation twice?</p>
  
  <p>Below is code: (<code>myClickHandler()</code> is a function for a button, <code>validation()</code> is a function where the validaton of my form occur)</p>
  
  <pre><code> function validation() {
  
                  var isDataValid = true;
  
                  var sessionNoO = document.getElementById("sessionNo");               
                  var questionNumberO = document.getElementById("txtQuestion");
                  var roomTextO = document.getElementById("room");
  
                  var errSessionMsgO = document.getElementById("sessionNoAlert");
                  var errQuesMsgO = document.getElementById("numberAlert");
                  var errRoomMsgO = document.getElementById("roomAlert");
  
                  var trimmedRoomText = roomTextO.value.replace(/^\s+/, '').replace(/\s+$/, '');
  
  
  
     if (sessionNoO.value == ""){
            errSessionMsgO.innerHTML = "Please Enter in the Number of Sessions you Require";
            isDataValid = false;   
      }else if (sessionNoO.value == 0){
          errSessionMsgO.innerHTML = "Number of Sessions Must be More than 0";
            isDataValid = false;
        }else{
                  errSessionMsgO.innerHTML = ""; 
              }
  
  
      if(questionNumberO.value == 0){
          errQuesMsgO.innerHTML = "Please Set the Number of Questions";
          isDataValid = false;
      } else {
          errQuesMsgO.innerHTML = "";
      } 
  
            if (roomTextO.value == ""){
            errRoomMsgO.innerHTML = "Please Enter in a Room Number";
            isDataValid = false;
              }else if (!trimmedRoomText.length){
            errRoomMsgO.innerHTML = "Please Enter in a Room Number"; 
            isDataValid = false;      
          }else{
                  errRoomMsgO.innerHTML = ""; 
              }
  
              return isDataValid;
  
              }
  
              function submitform()
              {
  
          var sessionFormO = document.getElementById("sessionForm");
  
          sessionFormO.submit();
  
              }    
  
  
      function myClickHandler()
      {
          if(validation())
          {
              showConfirm(); 
          }
      }
  
  
      function showConfirm()
      {
          var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session.Are you sure you want to Proceed? ");
  
          if (confirmMsg==true)
          {
              submitform();   
          } else {
              parent.close();    
          }
      }
  </code></pre>
  
  <p>Html code (The button which submits the form and displays confirmation box is below) :</p>
  
  <pre><code>&lt;form action="QandATable.php" method="post" id="sessionForm"&gt;
      &lt;p&gt;&lt;strong&gt;10: &lt;/strong&gt;&lt;input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="myClickHandler()"/&gt;&lt;/p&gt; 
  &lt;/form&gt;
  </code></pre>