Results 1 to 2 of 2

Thread: bg colour change on tick box selection

  1. #1
    Join Date
    Nov 2005
    Posts
    132
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default bg colour change on tick box selection

    hi,

    I'm hoping that css can render this, but accept that js may be the best solution.


    Background:
    I am designing a page where customers can buy bathroom suites plus a host of additional accessories. I display the suite name plus the price in a thin horizontal div (possibly a table - not totally decided yet) with a tick box at the end to confirm selection.

    Function:
    Is it possible to change the bg colour of this div when the tick box is ticked?
    I am very keen to keep the design colour-coded and clear.

    I would then repeat this functionality to the div's below which contain the accessory info.

    Hope this is clear enough..

    Many thanks in advance
    Neil

  2. #2
    Join Date
    Nov 2005
    Posts
    132
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    sorted, js though.


    <script>
    function changeBGColor(item, color)
    {
    var pItem = item.parentNode;
    while(pItem.nodeName != 'DIV')
    pItem = pItem.parentNode;

    pItem.style.backgroundColor = color;
    }
    </script>

    <div id="test"><p>Some text</p><input type="checkbox" id="testChk" onclick="changeBGColor(this, 'Red');" style="float: right;" /></div>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •