Connecting Tech Pros Worldwide Help | Site Map

how to enable/disable form elements by selecting check boxes from an array

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: Oct 9 '09
I am building up a table in php built from an array in a database. I can assign each row its own id's etc. But I need to enable or disable checkbox buttons and a text area depending on the checkbox for that row being checked or not.

hotellist.php
Expand|Select|Wrap|Line Numbers
  1. <div align="center"><input type="checkbox" name="en1" id="en1" onclick="enable1(this.checked)">
  2. <input type="hidden" name="editid" id="editid" value="<?php echo $id ?>" /></div>
  3.  
hotel.php
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function enable(obj)
  3. {
  4. var en1=document.getElementById("en1").value;
  5.     for(i=0;i<en1.length;i++)
  6.     {
  7.      if(en1[i].checked==true)
  8.      {
  9.          document.getElementById("en1").enabled=true;
  10.      }
  11.     }
  12. }
  13.  
  14. </script>
  15.  
  16.  
  17.  
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Oct 9 '09

re: how to enable/disable form elements by selecting check boxes from an array


Though this text is in a PHP file, it is not PHP, or I can at least assume it isn not PHP because what you have already tried is Javascript. Ergo, I will move this to the Javascript forum where you will get more appropriate answers.
Reply