Board index » javascript » a way to run through scripts on entire document?
|
grandeandy
Registered User |
a way to run through scripts on entire document?
2005-04-13 01:25:13 PM
what you see below is the code, which is two parts, a highlight part, and an unhighlight part. Below that is a sample of its use. What I am trying to do, is have some sort of javascript, or onload command in the body tag which will go through all of the 20-30 different <div>tags, and check the settings of each of those radio boxes. Why? because I am having the data editable in a form. Is there anyway to have say, a script click each radio box/input box that has been selected or typed in? here is the javascript code... function highlight(control) {var colour, div; if(control.value) {colour = '#f3f3f3';} else {colour = '#ffffff';} if((div = control.parentNode) && div.style) { div.style.backgroundColor = colour; } } function unhighlight(control) {var colour, div; if(control.value) {colour = '#ffffff';} else {colour = '#f3f3f3';} if((div = control.parentNode) && div.style) { div.style.backgroundColor = colour; } } <div class=divn id=dv23> Do you know javascript? <input type=radio name=disc value=NULL onclick="unhighlight(this);"> No Answer <input type=radio name=disc value=0 onclick="highlight(this);">Yes <input type=radio name=disc value=1 onclick="highlight(this);">No <br> Details: <br><textarea name=discd cols=60 rows=3></textarea> </div> - |
