#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Question Change Parent Style


    hi,

    i have page with checkboxlists, like

    <tr>
    <td>
    <input type="checkbox" >
    </td>
    </tr>
    <tr>
    <td>
    <input type="checkbox" checked="true" >
    </td>
    </tr>


    i need if select a checkbox , change its parent(td) style.

    plz help me.
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,188
    Rep Power
    184
    Code:
    <script>
    function showSel(checkBox,key)
    {
    if (checkBox.checked == true) {
    document.getElementById("checkboxes").getElementsByTagName("td")[key].style.backgroundColor="yellow";
    }
    else if (checkBox.checked == false) {
    document.getElementById("checkboxes").getElementsByTagName("td")[key].style.backgroundColor="white";
    }
    }
    </script>
    
    <table id="checkboxes">
    <tr>
    <td>
    <input type="checkbox" onclick="showSel(this,'0')">
    </td>
    </tr>
    <tr>
    <td style="background-color:yellow">
    <input type="checkbox" checked="true" onclick="showSel(this,'1')">
    </td>
    </tr>
    </table>

IMN logo majestic logo threadwatch logo seochat tools logo