Very simple method

 <select name="my_playlists" id="my_playlists" onchange="this.form.submit()">

Auto submit from javascript

<form id="my_form" action="/my_url" method="POST">
  <input type="text" name="one_time_code" />
  <input type="submit" id="SubmitCodeButton" value="Submit" />
</form>

  <script type="text/javascript" >

    //----- AUTO SUBMIT THE FORM - VALUE PASTED -----
    function submit_my_form() {
      document.getElementById('my_form').submit();
    }
    
  </script>

Auto submit from paste or key up

<form id="submit_received_code_form" action="/my_url" onsubmit="return DisablePageUntilReloaded()" method="POST">
  <input type="text" id="one_time_code" name="one_time_code" onpaste="check_field_value_entered()" minlength="4" maxlength="4" />
  <input type="submit" id="SubmitCodeButton" value="Submit" />
</form>


  <script type="text/javascript" >

    //----- AUTO SUBMIT THE FORM - VALUE PASTED -----
    function check_field_value_entered() {
      //Needs a delay so the pasted value is loaded into the input box
      setTimeout(function(e) {

        var value = document.getElementById('one_time_code').value;
        if (value.length == 4) {
          document.getElementById( 'SubmitCodeButton' ).style.display='none';
          document.getElementById( 'submit_received_code_form' ).submit();
        }
      }, 50);
    }
    
    //----- AUTO SUBMIT THE FORM - KEY UP EVENT -----
    jQuery(function() {
      var one_time_code = jQuery('#one_time_code');
      one_time_code.keyup(function() {
        if (one_time_code.val().length == 4) {
          document.getElementById( 'SubmitCodeButton' ).style.display='none';
          jQuery(this.form).submit();
        }
      });
    });
    
  </script>
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *