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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Gray out button images until checkbox checked

    Hello!
    I am trying to figure out a way to gray out my 2 buttons until one of the boxes is checked then respectively gray out again if no checkbox is checked. Does anyone have an Idea?? Javascript, CSS....whatever. I have attached a text file with my html code: gray_out_buttons.txt

    Thanks a bunch in advance!

    Brad
    Attached Files Attached Files

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Give this a try

    Give your buttons the respective id's

    id="bestprice"

    id="submit"

    Add id="myinputs" onclick="test()" to the opening UL tag for the checkboxes

    and put the following script in the head


    PHP Code:
    <script type='text/javascript'

    function 
    test(){
    isChecked=0
    theInputs
    =document.getElementById("myinputs").getElementsByTagName("INPUT")

    for(var 
    i=0;i<theInputs.length;i++){

    if(
    theInputs[i].checked==true){
    isChecked=1
    }

    }

    if(
    isChecked==1){
    document.getElementById("bestprice").disabled=false
    document
    .getElementById("submit").disabled=false
    }
    else{
    document.getElementById("bestprice").disabled=true
    document
    .getElementById("submit").disabled=true
    }

    }
    </script> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Still not working Jay.....

    Thanks for your help Jay!

    I tried what you said and still am not having any luck....I attached the code again in a text doc and also attached the image files. Thanks again!

    Brad
    Attached Thumbnails Attached Thumbnails Gray out button images until checkbox checked-find_best_price.gif   Gray out button images until checkbox checked-add_selected_to_cart.gif  
    Attached Files Attached Files

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    It looks like you'll have to swap the images as well, try the example in the attached zip file
    Attached Files Attached Files
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Awesome!

    Thanks a TON Mr J! Works like a charm.

    Brad


  •  

    Posting Permissions

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