Return to Snippet

Revision: 80314
at March 5, 2020 08:36 by dertimbo


Updated URL

                                

Updated Description
Clickable Form Labels for Safari and IE - prototype version

Revision: 1513
at October 14, 2006 11:43 by dertimbo


Initial Code
function fixFormLabels(){
	var labels;
	
	// enable for IE and Safari
	if( document.all || navigator.userAgent.indexOf("Safari") > 0){ 
		labels = document.getElementsByTagName("label");
		$A(labels).each ( function(label){
			Event.observe(label, "click", function(){ 
				var target = $(this.getAttribute('for'));
				// Checkboxes or radio button labels
				if(target.type == 'checkbox' || target.type == 'radio')
					target.checked = target.checked == false ? true : false;
				else // Textareas and input fields, Select elements
					target.focus();
			});
		});
	}
}

// execute the script when the page has loaded
Event.observe(window,"load", fixFormLabels);

Initial URL
http://www.freshlabs.de/journal/archives/2006/10/clickable-form-labels-for-safari-and-ie/

Initial Description

                                

Initial Title
Clickable Form Labels for Safari and IE - prototype version

Initial Tags
form, ie

Initial Language
JavaScript