title: updating the status of record, enable or disable in grid using prototype.js
body: <p>I am using prototype js with PHP and mysql for update the status of record enable to disable vice versa in a grid. For this i use Ajax.Request method of prototype. status is updating but status icon was not change. </p>
  
  <p>I am using image for showing enable or disable record.
  if record is enable in a grid then you can see enable.png image in a row of perticular record. Then i am changing the status of a perticular record in a grid, then status image should be changed with disable.png image in a grid for perticular record.
  In back end status has been changed but according to the current status image is not changing. 
  My code is:</p>
  
  <p>Step 1.</p>
  
  <pre><code>    &lt;?php
  require("Connection.php");
  
  $sql = "SELECT * from tbluser";
  
  $result=mysql_query($sql);
  
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="prototype.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="scriptaculous-js/src/scriptaculous.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="scriptaculous-js/src/unittest.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script language="javascript"&gt;
          function fnDeleteRecord(id)
          {
              new Ajax.Request('delete.php?action=Delete&amp;id='+id,{method:'get'});
              $(id).remove();
          }
  
      function fnUpdateStatus(id,value)
      {
          //new Ajax.Request('delete.php?action=Update&amp;id='+id+'&amp;status='+value, {method:'get',frequency:5,decay:3, onCreate: Ajax.Responders.register({onCreate: fnShowProcess(), onComplete:fnHideProcess()}), onSuccess:fnUpdateRecord});
          new Ajax.Request('delete.php?action=Update&amp;id='+id+'&amp;status='+value, {method:'get'});
  
      }
      function fnShowProcess()
      {
          var i = 0;
          if(Ajax.activeRequestCount &gt; 0)
  
          document.getElementById('a[i]').style.display = 'inline';
      }
      function fnHideProcess()
      {
          var i=0;
          if(Ajax.activeRequestCount &lt;= 0)
              document.getElementById('a[i]').style.display='none';
      }
      function fnUpdateRecord()
      {
          new Ajax.Updater('userrecords', 'index.php', {method:'post'});
      }
  &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;body&gt;
  &lt;table id="userrecords" border="1" cellpadding="0" cellspacing="0" width="700"&gt;
  
  &lt;tr&gt;
  
  &lt;th&gt; User Name &lt;/th&gt;
  
  &lt;th&gt; Password &lt;/th&gt;
  
  &lt;th&gt; Address &lt;/th&gt;
  
  &lt;th&gt; Phone Number &lt;/th&gt;
  
  &lt;th&gt; Action &lt;/th&gt;
  &lt;th&gt; Status &lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;?php
  
  while($row = mysql_fetch_array($result))
  
  {
  
  echo "&lt;tr id='".$row[id]."'&gt;";
  
  echo "&lt;td&gt;".$row['user_name']."&lt;/td&gt;";
  
  echo "&lt;td&gt;".$row['pass']."&lt;/td&gt;";
  
  echo "&lt;td&gt;".$row['address']."&lt;/td&gt;";
  
  echo "&lt;td&gt;".$row['phone_no']."&lt;/td&gt;";
  
  echo "&lt;td&gt;&lt;img src='images/spinner.gif' id='a[$row[id]]' alt=icon border=0 /&gt;&lt;a href='javascript:void(0);' onclick=fnDeleteRecord('".$row['id']."'); &gt;Delete&lt;/a&gt;&lt;/td&gt;";
  
  if($row['status'] == 'enabled')
      echo "&lt;td&gt;&lt;img src='images/spinner.gif' id='a[$row[id]]' alt=icon border=0 style='display:none;' /&gt;&lt;img src='images/enable.png' alt=icon border=0 onClick=fnUpdateStatus('".$row['id']."','disabled')  /&gt;&lt;/td&gt;";
  else if ($row['status'] == 'disabled')
      echo "&lt;td&gt;&lt;img src='images/spinner.gif' id='a[$row[id]]' alt=icon border=0 style='display:none;' /&gt;&lt;img src='images/disable.png' alt=icon border=0 onClick=fnUpdateStatus('".$row['id']."','enabled') /&gt;&lt;/td&gt;";
  
  echo "&lt;/tr&gt;";
  </code></pre>
  
  <p>}</p>
  
  <pre><code>echo "&lt;/table&gt;";
  
  mysql_close($con);
  </code></pre>
  
  <p>?>
  
  </p>
  
  <p>Step 2.</p>
  
  <pre><code>&lt;?php
  require_once('connection.php');
  
  if ($_GET['action'])
  {
      switch($_GET['action'])
      {
          case 'Delete':
              $sql = "Delete from tbluser where id ='".$_GET['id']."'";
              $result = mysql_query($sql);
              if(!$result)
                  echo "some problem occured during delete operation";
              break;
  
          case 'Update':
              echo $sql = "UPDATE tbluser SET status = '".$_GET['status']."' WHERE id = '".$_GET['id']."'";
              $result = mysql_query($sql);
              if(!$result)
                  echo 'some problem occured on server during update operation';
              break;
      }
  }
  ?&gt;
  </code></pre>