...

View Full Version : Gray out button images until checkbox checked



kidtoxic
02-10-2007, 10:21 PM
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

Mr J
02-10-2007, 10:37 PM
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



<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>

kidtoxic
02-11-2007, 12:01 AM
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

Mr J
02-11-2007, 08:38 AM
It looks like you'll have to swap the images as well, try the example in the attached zip file

kidtoxic
02-12-2007, 01:22 AM
Thanks a TON Mr J! Works like a charm.

Brad



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum