title: How can I find the state of a button from its value in JavaScript?
body: <p>I have written JavaScript which changes the value of the buttons when clicked. For example, the value of button changes from “Ignore Select” to “Enable Select” on click.</p>
  
  <p>My problem is how to find the state of the buttons as enabled or disabled using the value of the buttons. I tried to store element value in an array (var a[]="select";). but the button stops changing color which I have already done.Is there any other way to store the value of buttons in array??</p>
  
  <p>Here is the HTML code:</p>
  
  <pre><code>&lt;input type="button" name="Ignore Select" value="Ignore Select" id="select" onclick="colorchange('select')" style="background:rgb(255,145,0);"/&gt;
  &lt;input type="button" name="Ignore Delete" value="Ignore Delete" id="select1" onclick="colorchange('select1');" style="background:rgb(255,145,0);"/&gt;
  &lt;input type="button" name="Ignore Insert" value="Ignore Insert" id="select2" onclick="colorchange('select2');" style="background:rgb(255,145,0);"/&gt;
  &lt;input type="button" name="Ignore Update" value="Ignore Update" id="select3" onclick="colorchange('select3');" style="background:rgb(255,145,0);"/&gt;
  &lt;input type="button" name="Ignore Sleep" value="Ignore Sleep" id="select4" onclick="colorchange('select4');" style="background:rgb(255,145,0);"/&gt;
  </code></pre>
  
  <p>And the JavaScript:</p>
  
  <pre><code>&lt;script&gt;
  function colorchange(id) 
  {
     var elem = document.getElementById(id);
  if(id=="select")
   { 
    if (elem.value=="Ignore Select") 
    {
     elem.value = "Enable Select";
     var a[]="select";
    }
    else
    { 
     elem.value = "Ignore Select"; 
    }
   }
  
  if(id=="select1")
  {
   if (elem.value=="Ignore Delete") 
   {
     elem.value = "Enable Delete";
     var a[]="delete";
   }
   else
   { 
    elem.value = "Ignore Delete";
   }
  }
  
  if(id=="select2")
  {
   if (elem.value=="Ignore Insert")
   {
     elem.value = "Enable Insert";
    var a[]="insert";
   }
   else
   {
    elem.value = "Ignore Insert";
   }
  }
  
  if(id=="select3")
  {
   if (elem.value=="Ignore Update")
   {
     elem.value = "Enable Update";
     var a[]="update";
   }
   else
   {
    elem.value = "Ignore Update";
   }
  }
  
  if(id=="select4")
  {
   if (elem.value=="Ignore Sleep")
   {
     elem.value = "Enable Sleep";
     var a[]="sleep";
   }
   else
   {
    elem.value = "Ignore Sleep";
   }
  }
  }
  &lt;/script&gt; 
  </code></pre>
  
  <p>Thanks in advance.</p>