By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,640 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,640 IT Pros & Developers. It's quick & easy.

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

P: 1
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.

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>
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. }
  14. </script>
Oct 9 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 6,050
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.
Oct 9 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.