[Solved] Buttons must be pressed in a specific order to send the form – jquery


you can do something like this: foreach click on an answer button disabele the current button update the input value..and once the user clicks all answers button check if the combination is correct, if it is the case redirect your page.

$(function () {
    var correct_order="321";
    var clicks=0;
    var max_clicks=$('.answer').length;
    $('.answer').click(function(e) {
        clicks++;
        $('#text1').val($('#text1').val()+$(this).data('info'));  
        $(this).attr("disabled", true);
        if(clicks==max_clicks){
          if( $('#text1').val()==correct_order) {
               $('#answer_info').html("<p>Correct answer</p>");
               window.location.href = "https://yourpage";
          }
          else  {
               $('#answer_info').html("<p>Wrong answer</p>");
          }
        }

    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<form  method="POST">
<input type="text"  value="" id="text1" name="text1" style="width: 150px;" />
<br />
<input type="button" value="Click Me" id="1" class="answer"  data-info="1"/>
<input type="button" value="Click Me" id="2" class="answer"  data-info="2"/>
<input type="button" value="Click Me" id="3" class="answer"  data-info="3"/>

</form>
<div id="answer_info">

</div>

1

solved Buttons must be pressed in a specific order to send the form – jquery