From edbb4bfa9cff8f9226909f756036f2a8ca7bd460 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 5 Oct 2005 13:45:08 +0000 Subject: [PATCH] added function to set a style property in a given element-type and css-class --- etemplate/js/etemplate.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/etemplate/js/etemplate.js b/etemplate/js/etemplate.js index eb8276f4ad..7820d43863 100644 --- a/etemplate/js/etemplate.js +++ b/etemplate/js/etemplate.js @@ -151,3 +151,27 @@ function values2url(form,names) //alert('url='+url); return url+'&etemplate_exec_id='+form['etemplate_exec_id'].value; } + +// sets value (v) of style property (p) for all given elements of type (t) and class (c) +// eg. set_style_by_class('td','hide','visibility','visible') +function set_style_by_class(t,c,p,v) +{ + //alert('set_style_by_class('+t+','+c+','+p+','+v+')'); + var elements; + if(t == '*') { + // '*' not supported by IE/Win 5.5 and below + elements = (document.all) ? document.all : document.getElementsByTagName('*'); + } else { + elements = document.getElementsByTagName(t); + } + for(var i = 0; i < elements.length; i++){ + var node = elements.item(i); + for(var j = 0; j < node.attributes.length; j++) { + if(node.attributes.item(j).nodeName == 'class') { + if(node.attributes.item(j).nodeValue == c) { + eval('node.style.' + p + " = '" +v + "'"); + } + } + } + } +}