Change label background color on radio select

Hi,

I have this html code:
<label for="y1" class="radio_btn radio1">
	<input id="y1" name="connection_port_bot_angle" value="0" type="radio" class="r-input" <?php cps_checked(0, $conf['connection_port_bot_angle']); ?>>
</label>

Open in new window


And this CSS (just a part of it):

#cportsettings .r-input {
	margin: 8px;
}
#cportsettings .radio_btn {
	background: #e0e0e0;
	border: 1px solid #7b7b7b;
	-moz-border-radius: 16px;
	border-radius: 16px;
	
	-moz-box-shadow: 0px 0px 8px #aaa;
	-webkit-box-shadow: 0px 0px 8px #aaa;
	box-shadow: 0px 0px 8px #aaa;
}
#cportsettings .radio1 {
	position: absolute;
	top: 3px;
	left: 98px;
	z-index: 100;
}

Open in new window


- How can I change background color the label, when the input/radio is placed within it?
kgp43Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
I don't understand what you are asking.  What do you mean by "when the input/radio is placed within it?"


Cd&
0
Omer-PitouCommented:
.radio_btn {
      background-color: red;
}
0
kgp43Author Commented:
COBOLdinosaur; I was just referring to my input being placed within <label> tags, and the label need to change background when input radio is selected.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

kgp43Author Commented:
Omer-Pitou; Background need to be changed when radio is selected :)
0
COBOLdinosaurCommented:
Give the label an id for easy reference and then use an on click for the radio

<label id="radlabel" for="y1" class="radio_btn radio1">
	<input id="y1" name="connection_port_bot_angle" value="0" type="radio" class="r-input" 
          onclick="document.getElementById('rsdlabel').style.backgroundColor='blue';"
       <?php cps_checked(0, $conf['connection_port_bot_angle']); ?>>
</label>

Open in new window


Cd&
0
kgp43Author Commented:
that will not change background on the default selected one upon and will not de-select when a new radio is selected.
0
kgp43Author Commented:
Is it possible to make something like this with CSS:

"if radio is checked, then set background color of <label>"?

With this html setup:

<label for="y1" class="radio_btn radio1">
	<input id="y1" name="connection_port_bot_angle" value="0" type="radio" class="r-input" <?php cps_checked(0, $conf['connection_port_bot_angle']); ?>>
</label>

Open in new window

0
COBOLdinosaurCommented:
I am not going to play this game where you post a couple of lines of code and expect a guess to solve the problem.  You posted the code for one label and you got a solution for one label.  Post a link and give me the complete requirements or find someone else to help you because I am not interested in playing games.

Cd&
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.