Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/11/2007, 05:42
Avatar de Perovic
Perovic
 
Fecha de Ingreso: agosto-2006
Mensajes: 56
Antigüedad: 17 años, 8 meses
Puntos: 1
Re: Como poner un unico borde a una casilla de verificación de 1px de grosor y en gri

Aquí tienes la solución, espero que te ayude, no tengo documentación que pasasrte, pero bueno pegándote un poco lo entenderás :)...

Código:
//global variables that can be used by ALL the function son this page.
var inputs;
var imgFalse = '_style/_img/_desing/check-n.gif';
var imgTrue = '_style/_img/_desing/check-y.gif';

var tickTrue = '_style/_img/_desing/tick-y.gif';
var tickFalse = '_style/_img/_desing/tick-n.gif';

//this function runs when the page is loaded, put all your other onload stuff in here too.
function init() {
	replaceChecks();
	replaceTicks();
}

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 radio
		if(inputs[i].getAttribute('type') == 'radio') {
			
			//create a new image
			var img = document.createElement('img');
			
			//check if the radio 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 radio
			inputs[i].parentNode.insertBefore(img, inputs[i]);
			
			//hide the radio
			inputs[i].style.display='none';
		}
	}
}

function replaceTicks() {
	
	//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 radio
		if(inputs[i].getAttribute('type') == 'checkbox') {
			
			//create a new image
			var img = document.createElement('img');
			
			//check if the radio is checked
			if(inputs[i].checked) {
				img.src = tickTrue;
			} else {
				img.src = tickFalse;
			}

			//set image ID and onclick action
			img.id = 'tickImage'+i;
			//set image 
			img.onclick = new Function('tickChange('+i+')');
			//place image in front of the radio
			inputs[i].parentNode.insertBefore(img, inputs[i]);
			
			//hide the radio
			inputs[i].style.display='none';
		}
	}
}

//change the radio status and the replacement image
function tickChange(i) {

	if(inputs[i].checked) {
		inputs[i].checked = '';
		document.getElementById('tickImage'+i).src=tickFalse;
	} else {
		inputs[i].checked = 'checked';
		document.getElementById('tickImage'+i).src=tickTrue;
	}
}
//change the radio 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;