title: Checking whether checkbox is check and passing of data
body: <p>I'm trying to check whether the checkbox have been checked before it can proceed to update the data of the box that have been checked.</p>
  
  <p>This is my original code and it works fine but it is unable to check whether a checkbox have been checked:</p>
  
  <pre><code>echo'&lt;form name = "frmPrice" method="post" action=""&gt;';
      echo'&lt;table align="center"&gt;
            &lt;tr&gt;
               &lt;th&gt;&lt;/th&gt;
               &lt;th&gt;Types&lt;/th&gt;
               &lt;th&gt;Price&lt;/th&gt;
            &lt;/tr&gt;';
            while($row = mysql_fetch_assoc($result))
            {
              echo'&lt;tr&gt;';
              echo'&lt;td&gt;&lt;input type="checkbox" name="price[]" 
                    value='.$row['price_id'].'&lt;/td&gt;';
              echo'&lt;td&gt;'.$row['price_type'].'&lt;/td&gt;';
              echo'&lt;td&gt;'.$row['price_perunit'].'&lt;/td&gt;';
              echo'&lt;/tr&gt;';
             }    
     echo'&lt;/table&gt;';
     echo'&lt;br&gt;&lt;br&gt;&lt;input type="button" name="update" value="Update" 
            onClick="setUpdateAction();"/&gt;';
  echo'&lt;/form&gt;';
  </code></pre>
  
  <p>This one is the javascript for setUpdateAction(), price.js:</p>
  
  <pre><code>function setUpdateAction() {
  document.frmPrice.action = "update.php";
  document.frmPrice.submit();
  }
  </code></pre>
  
  <p>While the source code that I try to check for whether the box is checked or not is this and it can check for the checkbox but the problem now is that the data that is selected does not pass to the update.php:</p>
  
  <pre><code>echo'&lt;form name = "frmPrice" method="post" action=""&gt;';
          echo'&lt;table align="center"&gt;
                &lt;tr&gt;
                   &lt;th&gt;&lt;/th&gt;
                   &lt;th&gt;Types&lt;/th&gt;
                   &lt;th&gt;Price&lt;/th&gt;
                &lt;/tr&gt;';
                while($row = mysql_fetch_assoc($result))
                {
                  echo'&lt;tr&gt;';
                  echo'&lt;td&gt;&lt;input type="checkbox" name="price[]" 
                        value='.$row['price_id'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'.$row['price_type'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'.$row['price_perunit'].'&lt;/td&gt;';
                  echo'&lt;/tr&gt;';
                 }    
         echo'&lt;/table&gt;';
         echo'&lt;br&gt;&lt;br&gt;&lt;input type="submit" name="update" value="Update"/&gt;';
  echo'&lt;/form&gt;';
  
  if(isset($_POST['update']))
  {
     if(isset($_POST['price']))
     {
       echo "&lt;script language='javascript' type='text/javascript'&gt;";
       echo'function setUpdateAction() {
       document.frmPrice.action = "update.php";
       document.frmPrice.submit();}';
       echo "&lt;/script&gt;";
     }
     else
     {
       echo "&lt;script language='javascript' type='text/javascript'&gt;";
       echo "alert('You didn't select any data.')";
       echo "&lt;/script&gt;";
      }
  }
  </code></pre>
  
  <p>I think there is something wrong in my way of passing the data even though it now can check for whether a checkbox have been checked... </p>