
		lordhulk
		
		(usa Ubuntu)
		
		Enviado em 10/11/2010 - 07:10h 
		Olá Pessoal,
Eu estou com esse código abaixo, que funciona perfeitamente, mostrando o conteudo do <span> como uma hint, para todos os inputs e selects, porém eu gostaria de estender a ideia para checkboxes e radios, tentei ler a ideia e aplicar apenas trocando onde tinha input por checkbox mas nao tive resultado. Alguem poderia me ajudar?
Abraços
<script type="text/javascript">
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on mouseover, show the hint
			inputs[i].onmouseover = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onmouseout = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onmouseover = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onmouseout = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);
</script>