468,107 Members | 1,502 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

How can i read the Make all the Columns Editable on the Click of CheckBox

Hi Friends,

What is the way to iterate the Table and Make all the input types editable on the click of a checkbox.
Here is what My Requirement is :

Expand|Select|Wrap|Line Numbers
  1.         <table id="adSearchTable" cellspacing="3">
  2.             <thead>
  3.  
  4.                 <tr class="tableheader" style="height: 15px;">
  5.  
  6.                         <td class="tableheader" align="center">Name</td>
  7.  
  8.                         <td class="tableheader" align="center">Edit</td>                    
  9.  
  10.                         <td class="tableheader" align="center">Location</td>
  11.  
  12.                         <td class="tableheader" align="center">Salary</td>
  13.  
  14.                         <td class="tableheader" align="center">History</td>
  15.  
  16.                 </tr>
  17.  
  18.             </thead>
  19.             <tbody>
  20.                 <tr id="tr128009114">
  21.                     <td>Ashish</td>
  22.                         <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
  23.                         <td>
  24.                             <input name="tagLevelOptimizationBean[0].Location" value="Hisar" disabled="disabled" type="text">
  25.                         </td>
  26.                         <td>
  27.                             <input name="tagLevelOptimizationBean[0].Salary" value="12344" disabled="disabled" type="text">
  28.  
  29.                          </td>                       
  30.                          <td>
  31.                             <input name="tagLevelOptimizationBean[0].History" value="Software" disabled="disabled" type="text">
  32.                          </td>
  33.             </tr>
  34.         <tr id="tr128009115
  35. ">
  36.                     <td>Amit</td>
  37.                         <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
  38.                         <td>
  39.                             <input name="tagLevelOptimizationBean[0].Location" value="Pune" disabled="disabled" type="text">
  40.                         </td>
  41.                         <td>
  42.                             <input name="tagLevelOptimizationBean[0].Salary" value="352345" disabled="disabled" type="text">
  43.  
  44.                          </td>                       
  45.                          <td>
  46.                             <input name="tagLevelOptimizationBean[0].History" value="IT" disabled="disabled" type="text">
  47.                          </td>
  48.             </tr>
  49.  
  50.             </tbody>
  51.          </table>    
In this table, there may be any no of rows can exist. But i need to make the row editable to all columns (except First Column - > Name) when a checkbox of that row is clicked.

Can somebody tell me how to do this? Thanks for your replies in advance.
Feb 20 '08 #1
3 1186
Can Anybody help me out with this ?


Hi Friends,

What is the way to iterate the Table and Make all the input types editable on the click of a checkbox.
Here is what My Requirement is :

Expand|Select|Wrap|Line Numbers
  1.         <table id="adSearchTable" cellspacing="3">
  2.             <thead>
  3.  
  4.                 <tr class="tableheader" style="height: 15px;">
  5.  
  6.                         <td class="tableheader" align="center">Name</td>
  7.  
  8.                         <td class="tableheader" align="center">Edit</td>                    
  9.  
  10.                         <td class="tableheader" align="center">Location</td>
  11.  
  12.                         <td class="tableheader" align="center">Salary</td>
  13.  
  14.                         <td class="tableheader" align="center">History</td>
  15.  
  16.                 </tr>
  17.  
  18.             </thead>
  19.             <tbody>
  20.                 <tr id="tr128009114">
  21.                     <td>Ashish</td>
  22.                         <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
  23.                         <td>
  24.                             <input name="tagLevelOptimizationBean[0].Location" value="Hisar" disabled="disabled" type="text">
  25.                         </td>
  26.                         <td>
  27.                             <input name="tagLevelOptimizationBean[0].Salary" value="12344" disabled="disabled" type="text">
  28.  
  29.                          </td>                       
  30.                          <td>
  31.                             <input name="tagLevelOptimizationBean[0].History" value="Software" disabled="disabled" type="text">
  32.                          </td>
  33.             </tr>
  34.         <tr id="tr128009115
  35. ">
  36.                     <td>Amit</td>
  37.                         <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
  38.                         <td>
  39.                             <input name="tagLevelOptimizationBean[0].Location" value="Pune" disabled="disabled" type="text">
  40.                         </td>
  41.                         <td>
  42.                             <input name="tagLevelOptimizationBean[0].Salary" value="352345" disabled="disabled" type="text">
  43.  
  44.                          </td>                       
  45.                          <td>
  46.                             <input name="tagLevelOptimizationBean[0].History" value="IT" disabled="disabled" type="text">
  47.                          </td>
  48.             </tr>
  49.  
  50.             </tbody>
  51.          </table>    
In this table, there may be any no of rows can exist. But i need to make the row editable to all columns (except First Column - > Name) when a checkbox of that row is clicked.

Can somebody tell me how to do this? Thanks for your replies in advance.
Feb 21 '08 #2
vee10
141 100+
Hi,

This may solve ur problem

Expand|Select|Wrap|Line Numbers
  1. function check_click(id)
  2.     {
  3.     var ids=document.getElementById(id).getElementsByTagName("input"); 
  4.     var tableRow = document.getElementById(id).getElementsByTagName("input").length;           
  5.     for(i=1;i<parseInt(tableRow);i++)
  6.     {
  7.     if(document.getElementById(id).getElementsByTagName("input").item(i).disabled==0)    
  8.     document.getElementById(id).getElementsByTagName("input").item(i).disabled=1; 
  9.     else
  10.     document.getElementById(id).getElementsByTagName("input").item(i).disabled=0; 
  11.     }
  12.     }
Feb 21 '08 #3
acoder
16,027 Expert Mod 8TB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for everyone to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

Thanks!
Feb 21 '08 #4

Post your reply

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

Similar topics

2 posts views Thread by /.. | last post: by
3 posts views Thread by Angela Chen | last post: by
reply views Thread by Luis Esteban Valencia | last post: by
4 posts views Thread by biswaranjan.rath | last post: by
4 posts views Thread by farhaaad | last post: by
4 posts views Thread by Steve Kershaw | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.