Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Changing row color on clicking radio button

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 319
    Comment on it

    Consider an HTML table with multiple rows having radio button in first column of each row. Now, if we want to change the row color when radio button associated with it is clicked, we have to write following code.

    // HTML //

    Untitled

    text
    text
    text
    text

    // CSS //

    body {
        margin:10px; padding:0px;
        background:#fff;
    }
    td {
    border-style: solid;
    border-width: 1px;
    font-size:15px;
    padding:5px;
    text-align:center;
    }
    .radiotd{width:15px}
    

    // Java Script //

    function setrow(row) {
        // Clear all rows each time
        for (i=1; i<5; i++) {
            var elem = 'r' + i;
            document.getElementById(elem).style.background = "#fff";
        }
        // set desired row
        document.getElementById(row).style.background = "#ddd";
        return true;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: