How to fix Double click button?

How to fix Double click button?

Hi guys,

I have this button below, the problem is I need to double click it before the form will submit.
  1. <?php
  2. if($data_completion != FALSE) { //If lesson already taken, disable submit button. 
  3. ?>
  4. <input type="image" name="submitlesson" alt="Submit Lesson" src="<?php echo base_url('images/buttoncomplete1.jpg'); ?>" onmouseover="this.src='<?php echo base_url('images/buttoncomplete2.jpg'); ?>'" onmouseout="this.src='<?php echo base_url('images/buttoncomplete1.jpg'); ?>'" value="submit" disabled>
  5. <?php
  6. } else {
  7. //If lesson not yet taken, enable submit button.
  8. //Decide weather essay or multiple choice button.
  9. //Essay button  
  10. if($data_lesson['essay'] == 'true') {
  11. ?>
  12. <input type="image" id="buttonessay" name="submitlesson" alt="Submit Lesson" src="<?php echo base_url('images/buttoncomplete1.jpg'); ?>" onmouseover="this.src='<?php echo base_url('images/buttoncomplete2.jpg'); ?>'" onmouseout="this.src='<?php echo base_url('images/buttoncomplete1.jpg'); ?>'" value="submit">
  13. <div id="btn"></div>
  14. <?php
  15. }

  16. //Multiple choice button
  17. if($data_lesson['essay'] == 'false') {
  18. ?>
  19. <input type="image" id="buttonmc" name="submitlesson" alt="Submit Lesson" src="<?php echo base_url('images/buttoncomplete1.jpg'); ?>" onmouseover="this.src='<?php echo base_url('images/buttoncomplete2.jpg'); ?>'" onmouseout="this.src='<?php echo base_url('images/buttoncomplete1.jpg'); ?>'" value="submit">
  20. <div id="btn"></div>
  21. <?php
  22. }
  23. }
  24. ?>
As you can see I have three buttons base from the above codes.
The double click happens on the id="buttonessay" button.


Below are the jQuery Codes.
  1. <script type="text/javascript">
  2. $(function() {
  3. /*** Menu begin. ***/
  4. var menu_ul = $('.menu > li > ul'),
  5.   menu_a  = $('.menu > li > a');
  6. //menu_ul.hide();
  7. menu_a.click(function(e) {
  8. e.preventDefault();
  9. if(!$(this).hasClass('active')) {
  10. menu_a.removeClass('active');
  11. menu_ul.filter(':visible').slideUp('normal');
  12. $(this).addClass('active').next().stop(true,true).slideDown('normal');
  13. } else {
  14. $(this).removeClass('active');
  15. $(this).next().stop(true,true).slideUp('normal');
  16. });
  17. /*** Menu end. ***/
  18. /*** Tooltip begin. ***/
  19. //$("#submit1").click(function(){
  20. $( "form" ).submit(function( event ) {
  21. if ($("#op1").is(":checked")) {
  22. var user_choice = "option1";
  23. var correct_choice = document.getElementById('correct_choice').value;
  24. var message = document.getElementById('op1').value;

  25. if (user_choice == correct_choice) { //Submit form if answer is correct
  26. $("input[id='answermc']").val("1");
  27. $("#tooltip").hide();
  28. return;
  29. } else {
  30. //$("#tooltip").html("msg: " + (message) + "<br>User: " + (user_choice) + "<br>Correct: " + (correct_choice)).show();
  31. $("#tooltip").html(message).show();
  32. event.preventDefault(); //Prevent submission of form.
  33. }
  34. event.preventDefault(); //Prevent submission of form.
  35. }

  36. if ($("#op2").is(":checked")) {
  37. var user_choice = "option2";
  38. var correct_choice = document.getElementById('correct_choice').value;
  39. var message = document.getElementById('op2').value;

  40. if (user_choice == correct_choice) { //Submit form if answer is correct
  41. $("input[id='answermc']").val("2");
  42. $("#tooltip").hide();
  43. return;
  44. } else {
  45. //$("#tooltip").html("msg: " + (message) + "<br>User: " + (user_choice) + "<br>Correct: " + (correct_choice)).show();
  46. $("#tooltip").html(message).show();
  47. event.preventDefault(); //Prevent submission of form.
  48. }
  49. event.preventDefault(); //Prevent submission of form.
  50. }

  51. if ($("#op3").is(":checked")) {
  52. var user_choice = "option3";
  53. var correct_choice = document.getElementById('correct_choice').value;
  54. var message = document.getElementById('op3').value;

  55. if (user_choice == correct_choice) { //Submit form if answer is correct
  56. $("input[id='answermc']").val("3");
  57. $("#tooltip").hide();
  58. return;
  59. } else {
  60. //$("#tooltip").html("msg: " + (message) + "<br>User: " + (user_choice) + "<br>Correct: " + (correct_choice)).show();
  61. $("#tooltip").html(message).show();
  62. event.preventDefault(); //Prevent submission of form.
  63. }
  64. event.preventDefault(); //Prevent submission of form.
  65. }

  66. if ($("#op4").is(":checked")) {
  67. var user_choice = "option4";
  68. var correct_choice = document.getElementById('correct_choice').value;
  69. var message = document.getElementById('op4').value;

  70. if (user_choice == correct_choice) { //Submit form if answer is correct
  71. $("input[id='answermc']").val("4");
  72. $("#tooltip").hide();
  73. return;
  74. } else {
  75. //$("#tooltip").html("msg: " + (message) + "<br>User: " + (user_choice) + "<br>Correct: " + (correct_choice)).show();
  76. $("#tooltip").html(message).show();
  77. event.preventDefault(); //Prevent submission of form.
  78. }
  79. event.preventDefault(); //Prevent submission of form.
  80. }
  81. //Submit form if essay button is click
  82. $( "#buttonessay" ).click(function() {
  83. $( "form" )[0].submit();
  84. //$( "form" ).submit();
  85. //return;
  86. });
  87. event.preventDefault(); //Prevent submission of form.
  88. });
  89. //Hide tooltip When outside tooltip is click.
  90. $(document).mouseup(function (e)
  91. {
  92. var container = $("#tooltip");
  93. if (!container.is(e.target) // if the target of the click isn't the container...
  94. && container.has(e.target).length === 0) // ... nor a descendant of the container
  95. {
  96. container.hide();
  97. }
  98. });
  99. /*** Tooltip end. ***/                                                       
  100. });
  101. </script>

What is causing the double click?


Thanks in advance whoever will help me.