SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $5 to anyone who can get this to work.

    SOLVED
    Last edited by Darren884; Nov 26, 2005 at 13:36.
    Have a good day.

  2. #2
    d^_^b Iain G's Avatar
    Join Date
    Nov 2005
    Location
    Gloucester, UK
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very difficult without seeing the code.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol. That's below minimum wage!

    1) Create a function that disables the 4 fields when you pass it the elements array of the form.

    myFormElements["color"].disabled = true;
    myFormElements["color"].style.backgroundColor = "buttonface";
    etc.

    Also create another function that enables the 4 fields when you pass it the elements array of the form.

    myFormElements["color"].disabled = false;
    myFormElements["color"].style.backgroundColor = "white";
    etc.

    2) In a separate window.onload function:

    ---get the elements array of the form
    ---send your function the elements array to disable all the fields
    ---if "text" is going to be showing in the select as the default, enable the color field:
    myFormElements["color"].disabled = "false";
    myFormElements["color"].style.backgroundColor = "white";

    3) In the window.onload function also get the select and assign a function(which will do the disabling/enabling) to the select's onchange event handler:

    document.getElementById("mySelect").onchange = function() {.....};

    4) In the onchange function, first get the select's selectedIndex property. Then setup a switch() statement to handle the 3 possibilites: 0(text), 1(image), 2(invisible).

    For case 0, call your disableAll() function, then enable just the 'color' element:

    myFormElements["color"].disabled = false;
    myFormElements["color"].style.backgroundColor = white;

    For case 1, call your enableAll() function.

    For case 2, call your disableAll() function.

    easy, peasy.
    Last edited by 7stud; Nov 25, 2005 at 06:52.

  4. #4
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please explain better? I am a novice at javascript...
    Have a good day.

  5. #5
    d^_^b Iain G's Avatar
    Join Date
    Nov 2005
    Location
    Gloucester, UK
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Show us the code you already have.

  6. #6
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Darren,

    There is a thread already open for this problem. If you have a look at the javascript I wrote earlier, that might get you sorted out.

    Cheers;
    Poncho
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate


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
  •