Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Directory Submission Service   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2007, 09:08 PM   #1 (permalink)
Contributing Member
 
Mr.Bill's Avatar
 
Join Date: 06-21-07
Posts: 238
iTrader: 2 / 100%
Mr.Bill is liked by many
Help with a possible CSS issue

How would I go about changing the default color of a check box from white to another color.

PHP Code:
<input type="checkbox" id="fa" name="fa" /><label for="fa"Remove ads</label
I tried to add a class then added a line to the css for color and also tried background color got no results how would this possible?
Mr.Bill is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 07-24-2007, 10:27 AM   #2 (permalink)
Contributing Member
 
LiamSwan's Avatar
 
Join Date: 07-24-07
Posts: 132
iTrader: 0 / 0%
Latest Blog:
None

LiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really nice
Checkboxes, and radio buttons cannot be altered using css, they are rendered by the visitors operating system. There is no way to get around it.

(You could change the border colors for checkboxes using css but I don't think any browser other than IE will work that way)

The key to changing their appearance is by not displaying checkboxes at all, use an image instead, and glue it together with a few lines of JavaScript

What happens is that when the page is loaded a JavaScript will scan the page for checkboxes and hide them and place an image in the same position, which will act exactly like a normal checkbox.
LiamSwan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-24-2007, 10:59 AM   #3 (permalink)
Contributing Member
 
Mr.Bill's Avatar
 
Join Date: 06-21-07
Posts: 238
iTrader: 2 / 100%
Mr.Bill is liked by many
Found this but it has a padding issue in FF2

Code:
<script> function changecolor(obj){ if (obj.checked) obj.parentNode.style.backgroundColor='green' else obj.parentNode.style.backgroundColor='red'} </script> <form> <div style="width:14px;height:14px;clip:rect(0 14 14 0);overflow:hidden;"> <span style="background-color: red;position:relative;top:-3px;left:-3px;"> <input onclick="changecolor(this)" type="checkbox" style="margin:0; padding:0; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50); -moz-opacity:0.5"> </span></div> </form>
I like the image idea better
Mr.Bill is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-24-2007, 11:08 AM   #4 (permalink)
Contributing Member
 
LiamSwan's Avatar
 
Join Date: 07-24-07
Posts: 132
iTrader: 0 / 0%
Latest Blog:
None

LiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really nice
Add this between the head tags
Code:
<script type="text/javascript" src="checkbox.js"></script>
Create checkbox.js and insurt it into your directory
The following is the content of checkbox.js
You don't need to understand it, just embed it into your page and it'll work
The only thing you may want to change (/add) are the false.png and true.png

Code:
//global variables that can be used by ALL the function son this page. var inputs; var imgFalse = 'false.png'; var imgTrue = 'true.png'; //this function runs when the page is loaded, put all your other onload stuff in here too. function init() { replaceChecks(); } function replaceChecks() { //get all the input fields on the page inputs = document.getElementsByTagName('input'); //cycle trough the input fields for(var i=0; i < inputs.length; i++) { //check if the input is a checkbox if(inputs[i].getAttribute('type') == 'checkbox') { //create a new image var img = document.createElement('img'); //check if the checkbox is checked if(inputs[i].checked) { img.src = imgTrue; } else { img.src = imgFalse; } //set image ID and onclick action img.id = 'checkImage'+i; //set image img.onclick = new Function('checkChange('+i+')'); //place image in front of the checkbox inputs[i].parentNode.insertBefore(img, inputs[i]); //hide the checkbox inputs[i].style.display='none'; } } } //change the checkbox status and the replacement image function checkChange(i) { if(inputs[i].checked) { inputs[i].checked = ''; document.getElementById('checkImage'+i).src=imgFalse; } else { inputs[i].checked = 'checked'; document.getElementById('checkImage'+i).src=imgTrue; } } window.onload = init;
LiamSwan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-24-2007, 11:34 AM   #5 (permalink)
Contributing Member
 
Mr.Bill's Avatar
 
Join Date: 06-21-07
Posts: 238
iTrader: 2 / 100%
Mr.Bill is liked by many
Incredible that is very nice thank you. Now if I could figure our how to add REP i would give some. I appreciate this
Mr.Bill is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-24-2007, 04:35 PM   #6 (permalink)
Contributing Member
 
LiamSwan's Avatar
 
Join Date: 07-24-07
Posts: 132
iTrader: 0 / 0%
Latest Blog:
None

LiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really nice
Good luck with whatever it is your doing.
LiamSwan is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
www and non www issue webexplore Google Forum 9 09-15-2007 04:59 PM
WOMD - Issue or Non-issue John Scott Politics 1 08-02-2007 08:30 AM
CSS Issue Sketch Coding Forum 7 02-16-2007 05:13 PM
css issue in IE6 sachi Coding Forum 8 02-05-2007 11:57 AM
CSS issue Laurentvw Coding Forum 3 04-03-2006 09:46 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:01 PM.
© Copyright 2008 V7 Inc

Click Here