0

I am displaying a graph on my webpage and there is a button called "redraw". So i want to disable the button redraw once clicked till the graph is drawn and enable the redraw button again.. using javascript . The graph and button is on the same page This is my javascript

 <script>
  $("#myButton").on('click', function () {
  $(this).prop('disabled', true);
  $(this).toggleClass('green');
  $("#result").toggle();
 });
 </script>
madth3
  • 7,275
  • 12
  • 50
  • 74
Ashoka
  • 452
  • 1
  • 5
  • 20
  • WOW.. give us some more information please, what graph API are you using? Show us some code! – Eric Aug 22 '13 at 10:10
  • possible duplicate of [javascript disable and re-enable a button?](http://stackoverflow.com/questions/8394562/javascript-disable-and-re-enable-a-button) – Felix Kling Aug 22 '13 at 10:13
  • hey guys obliged to u forsuch a huge response to my ques ..Anyways i got the answer ..i am using onclick="this.form.submit();this.disabled=true;" – Ashoka Aug 23 '13 at 06:12

3 Answers3

1

To enable

document.getElementById("btnID").disabled = false; 

To Disable

document.getElementById("btnID").disabled = true; 

Put it in an approprite place in your code to achieve what you want. There are many version of this available please google. Please don't vote up as it is commonly known.

NOTE: You have to try something before asking any question. Always support your question with code/analysis you have done.

Akki619
  • 2,386
  • 6
  • 26
  • 56
0

you have to use:

  document.getElementById('redrawid').disabled = 1; for disabling.

and

  document.getElementById('redrawid').disabled = 0; for enabling the button.
shemy
  • 573
  • 1
  • 5
  • 15
0

Use like this,

 $('#redrawid').attr('disabled', 'disabled');

to disable the element

 $('#redrawid').removeAttr('disabled');

to enable the element again

Manu M
  • 1,074
  • 5
  • 17