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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AshishMishra16
    New Member
    • May 2007
    • 4

    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 :

    Code:
            <table id="adSearchTable" cellspacing="3">
                <thead>
                    
                    <tr class="tableheader" style="height: 15px;">
                        
                            <td class="tableheader" align="center">Name</td>
                        
                            <td class="tableheader" align="center">Edit</td>                    
                        
                            <td class="tableheader" align="center">Location</td>
                                            
                            <td class="tableheader" align="center">Salary</td>
                        
                            <td class="tableheader" align="center">History</td>
                        
                    </tr>
    
                </thead>
                <tbody>
                    <tr id="tr128009114">
                    	<td>Ashish</td>
                            <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Location" value="Hisar" disabled="disabled" type="text">
                            </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Salary" value="12344" disabled="disabled" type="text">
    
                             </td>                       
                             <td>
                                <input name="tagLevelOptimizationBean[0].History" value="Software" disabled="disabled" type="text">
                             </td>
        		</tr>
    		<tr id="tr128009115
    ">
                    	<td>Amit</td>
                            <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Location" value="Pune" disabled="disabled" type="text">
                            </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Salary" value="352345" disabled="disabled" type="text">
    
                             </td>                       
                             <td>
                                <input name="tagLevelOptimizationBean[0].History" value="IT" disabled="disabled" type="text">
                             </td>
        		</tr>
    
                </tbody>
             </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.
  • AshishMishra16
    New Member
    • May 2007
    • 4

    #2
    Can Anybody help me out with this ?


    Originally posted by AshishMishra16
    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 :

    Code:
            <table id="adSearchTable" cellspacing="3">
                <thead>
                    
                    <tr class="tableheader" style="height: 15px;">
                        
                            <td class="tableheader" align="center">Name</td>
                        
                            <td class="tableheader" align="center">Edit</td>                    
                        
                            <td class="tableheader" align="center">Location</td>
                                            
                            <td class="tableheader" align="center">Salary</td>
                        
                            <td class="tableheader" align="center">History</td>
                        
                    </tr>
    
                </thead>
                <tbody>
                    <tr id="tr128009114">
                    	<td>Ashish</td>
                            <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Location" value="Hisar" disabled="disabled" type="text">
                            </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Salary" value="12344" disabled="disabled" type="text">
    
                             </td>                       
                             <td>
                                <input name="tagLevelOptimizationBean[0].History" value="Software" disabled="disabled" type="text">
                             </td>
        		</tr>
    		<tr id="tr128009115
    ">
                    	<td>Amit</td>
                            <td> <input name="tagLevelOptimizationBean[0].optimize" value="on" type="checkbox"> </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Location" value="Pune" disabled="disabled" type="text">
                            </td>
                            <td>
                                <input name="tagLevelOptimizationBean[0].Salary" value="352345" disabled="disabled" type="text">
    
                             </td>                       
                             <td>
                                <input name="tagLevelOptimizationBean[0].History" value="IT" disabled="disabled" type="text">
                             </td>
        		</tr>
    
                </tbody>
             </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.

    Comment

    • vee10
      New Member
      • Oct 2006
      • 141

      #3
      Hi,

      This may solve ur problem

      [CODE=javascript]function check_click(id)
      {
      var ids=document.ge tElementById(id ).getElementsBy TagName("input" );
      var tableRow = document.getEle mentById(id).ge tElementsByTagN ame("input").le ngth;
      for(i=1;i<parse Int(tableRow);i ++)
      {
      if(document.get ElementById(id) .getElementsByT agName("input") .item(i).disabl ed==0)
      document.getEle mentById(id).ge tElementsByTagN ame("input").it em(i).disabled= 1;
      else
      document.getEle mentById(id).ge tElementsByTagN ame("input").it em(i).disabled= 0;
      }
      }[/CODE]
      Last edited by acoder; Feb 21 '08, 11:15 AM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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!

        Comment

        Working...