amtemplates strict
[kivitendo-erp.git] / js / highlight_input.js
1 //Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
2 //For full source code, 100's more DHTML scripts, and TOS,
3 //visit http://www.dynamicdrive.com
4
5 var highlightcolor="yellow"
6
7 var ns6=document.getElementById&&!document.all
8 var previous=''
9 var eventobj
10
11 //Regular expression to highlight only form elements
12 var intended=/INPUT|TEXTAREA|SELECT|OPTION/
13
14 //Function to check whether element clicked is form element
15 function checkel(which){
16 if (which.style&&intended.test(which.tagName)){
17 if (ns6&&eventobj.nodeType==3)
18 eventobj=eventobj.parentNode.parentNode
19 return true
20 }
21 else
22 return false
23 }
24
25 //Function to highlight form element
26 function highlight(e){
27 eventobj=ns6? e.target : event.srcElement
28 if (previous!=''){
29 if (checkel(previous))
30 previous.style.backgroundColor=''
31 previous=eventobj
32 if (checkel(eventobj))
33 eventobj.style.backgroundColor=highlightcolor
34 }
35 else{
36 if (checkel(eventobj))
37 eventobj.style.backgroundColor=highlightcolor
38 previous=eventobj
39 }
40 }