chiefrokka Posted February 21, 2008 Share Posted February 21, 2008 I'm creating dynamic radio buttons but for certain ones I want to disable depending on criteria from database. disabling works fine but I also want to change the color of the button or do something so it stands out more. can someone help me do this. thanks Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/ Share on other sites More sharing options...
craygo Posted February 21, 2008 Share Posted February 21, 2008 this is more of a css question, but the basics would be. 1 create the multiple classes in css 2 when you query the database you would select the class you wish to use 3 apply the class to the radio button Ray Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-472994 Share on other sites More sharing options...
chiefrokka Posted February 21, 2008 Author Share Posted February 21, 2008 if you don't mind, could you post an example of how to do that exactly? i'm not familiar with classes and css. sorry if this isn't really a php question I guess, but you guys are the best! I tried this but it didn't really work: <style type="text/css"> <!-- body { background-image: url(); background-repeat: repeat; } .radiobutton { background : #FFCC00; color : #FF0000 } --> </style> <input class="radiobutton" type="radio" name="Pick" value="Team2" id="Pick"> Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473005 Share on other sites More sharing options...
bpops Posted February 21, 2008 Share Posted February 21, 2008 I'm not sure you have much control over the color of radio buttons, but you could always try something like this: http://www.outfront.net/tutorials_02/adv_tech/funkyforms4.htm (first result of a google search for css radio buttons) Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473011 Share on other sites More sharing options...
chiefrokka Posted February 21, 2008 Author Share Posted February 21, 2008 ya i looked at that page and tried it. didn't work. I'm using Firefox and seems like certain browsers handle radio button attributes differently? I don't know how he wrote the class "Red" though so maybe that's why? Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473016 Share on other sites More sharing options...
bpops Posted February 21, 2008 Share Posted February 21, 2008 Input types can be hard to obey CSS commands with some browsers. If it were me I'd probably enclose it in a div and style the div behind the button. Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473023 Share on other sites More sharing options...
craygo Posted February 21, 2008 Share Posted February 21, 2008 Well here's an example <style> .input.r1{ background-color: #CCCCFF; border: 1px dotted #9900FF; font-size: 15px; color: red; } .input.r2{ background-color: red; border: 1px solid #9900FF; font-size: 15px; color: green; } </style> then in php after you query the table you can use a switch or an if then to select switch($fieldname){ case "1": $class = "r1"; break; case "2": $class = "r2"; break; default: $class = ""; } echo "<input type=radio class=$class name=somename>\n"; Ray Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473058 Share on other sites More sharing options...
chiefrokka Posted February 21, 2008 Author Share Posted February 21, 2008 thanks ray, but unless i did something wrong your code didn't work with my Firefox browser. I copied/pasted your styles and then pasted your input <?php if ($flag == 1) { echo "<input type=radio class='r1' name='Pick' id='Pick' value='Team1' disabled>\n"; } else { echo "<input type=radio class='r2' name='Pick' id='Pick' value='Team1' >\n"; } ?> hmm... stupid radio buttons. lol Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473084 Share on other sites More sharing options...
craygo Posted February 21, 2008 Share Posted February 21, 2008 Well that's another problem all together, firefox may not be compatible with radio button styles. I tried the example in IE and it works fine, but firefox doesn't. Sorry just the way it is. Ray Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473108 Share on other sites More sharing options...
chiefrokka Posted February 21, 2008 Author Share Posted February 21, 2008 oh well. i'll have to try putting it in a <div> like mentioned above. I noticed Firefox doesn't display table colors that well either like IE Link to comment https://forums.phpfreaks.com/topic/92316-changing-color-of-radio-buttons/#findComment-473120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.