Posted By

dertimbo on 10/14/06


Tagged

form ie safari label


Versions (?)



Who likes this?

1 person has marked this snippet as a favorite

rnrleachryan


Clickable Form Labels for Safari and IE - prototype version


Published in: JavaScript 



Website Promotion
DIRECTORY
is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


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

Expand | Embed | Plain Text
  1. function fixFormLabels(){
  2. var labels;
  3.  
  4. // enable for IE and Safari
  5. if( document.all || navigator.userAgent.indexOf("Safari") > 0){
  6. labels = document.getElementsByTagName("label");
  7. $A(labels).each ( function(label){
  8. Event.observe(label, "click", function(){
  9. var target = $(this.getAttribute('for'));
  10. // Checkboxes or radio button labels
  11. if(target.type == 'checkbox' || target.type == 'radio')
  12. target.checked = target.checked == false ? true : false;
  13. else // Textareas and input fields, Select elements
  14. target.focus();
  15. });
  16. });
  17. }
  18. }
  19.  
  20. // execute the script when the page has loaded
  21. Event.observe(window,"load", fixFormLabels);

Report this snippet 

You need to login to post a comment.