1

I have button(in future many), and form. What i want, that after submit of the page that call form became not available.

enter image description here

But after submit page is upload. How to avoid this?

   <script type="text/javascript">
          $(function()   {

              var btn =  $('#btn1');
              var form = $('#myform');
              var formbtn =   $('#submit');

               btn.on ('mouseup', function(){
                     form.toggle(200);


           });

           formbtn.on('mouseup', function(){
              btn.html('bought!');
               btn.attr('disable', true);
              return false;
           });


        });


 <div id = "myform">

        <form id = "my">
        <div class="form-group">
    <label for="exampleInputEmail1">Name</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Phone</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>


  <button id="submit"  class="btn btn-default">Submit</button>
</form>

    </div>

And how in future choice button to disable from the plurality of buttons, it will be some array?

Anubhab
  • 749
  • 1
  • 9
  • 18
user202822
  • 89
  • 1
  • 1
  • 8

1 Answers1

2

To answer the first part of your question, you will want to change

btn.attr('disable', true);

to

btn.attr('disabled', 'disabled');

For the second part of your question, if I understand correctly, you could use a class or element selector for multiple buttons

$('button')
$('.buttonClass')

To add, depending on the version of jQuery, you may want to use .prop instead of .attr for 1.6+.

See this answer for more information - https://stackoverflow.com/a/6048113/1927071

Community
  • 1
  • 1
KC-Flip
  • 132
  • 4
  • 10