Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Color Selection Problem.

    Hey guys,
    i am using the color selector from http://www.dynamicdrive.com/dynamici...cker/index.htm
    and have com across a problem, if you use the color selector it fills a color box next to the text field, i would like it to fill that box and also another one on the same page, but after i add another div with the same ID it doesn't load the second one as well, but if i delete the first one the second one starts working, is there a way i can make the 2 color box's work simultaneously?

    thanks for any help

    baleric

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    it doesnt work because the script probably calls to the element by id. and the first elemement it sees with that specific id is the only one it will change. you will haveto add in another line to specify the second div (give it a different id).
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    id must be unique on the same page/session. Give another id to your second element , and (not an elegant method, but it allows you to avoid modify the code) repeat the called function passing that id as parameter:

    onfocus="ddcolorposter.echocolor(this, 'colorbox1');ddcolorposter.echocolor(this, 'colorotherbox1')"
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the help guys,

    Code:
    onfocus="ddcolorposter.echocolor(this, 'colorbox1') ; ddcolorposter.echocolor(this, 'colorotherbox1')"
    that wasn't successful, i was really hoping that would work im a bit of a javascript noob,
    it only changes the last ddcolorposter command, so wateva colorbox is last thats what changes.
    is there any other way to do this without changing the main code?
    Last edited by Baleric; 12-02-2006 at 06:21 AM.


  •  

    Posting Permissions

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