Results 1 to 2 of 2

Thread: Change A Table BG Color From A Image Button

  1. #1
    Join Date
    Mar 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Change A Table BG Color From A Image Button

    ok i need some help coding a script...i want to be able to change a table bg image not its color from a another image *Button*..there are 6 buttons, different colors, i want the background image of a table change to each button color that is clicked...the buttons will be at the top and the table image i want to be able to change will be under the buttons....is this possible? please help

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Does this help you?
    Code:
    <script type='text/javascript'>
    function change_bg(hex, id){
    document.getElementById(id).style.background="#"+hex;
    }
    </script>
    <button onClick="change_bg('0000A5','table_d');">Color1</button> <button onClick="change_bg('7272A3','table_d');">Color2</button>
    <button onClick="change_bg('FF967C','table_d');">Color3</button>
    <table width="500" height="500" id="table_d"><tr><td></td></tr></table>
    Now, all you need to do is add buttons, you should do it like this(the onClick).
    Code:
    cahnge_bg('hex_code_without_#','id')
    Jeremy | jfein.net

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
  •