Get dynamically given div id's from document
<p>I'm not a developer but I've been dabbling around with this for a while. Hope you can help</p>

<p>I have several div's with ID:s that are given to them dynamically through php. I have a function that is called through a checkbox which hides and shows the divs. What I want to do now is to get the div ids from the document and put them into the function.</p>

<p>I've kind of copied codes from different forums and it works if I'm hard coding the div names. Not sure what I'm doing now though, any help would be appreciated.</p>

<p>Here's what I have</p>

<p>Assigns id's to the divs:</p>

<pre><code>$a .= "&lt;div id='$go[media_caption]" . $i . "'&gt;";
</code></pre>

<p>The function:</p>

<pre><code>var editorial = [id^='editorial']);

function visiblox(arrDiv, hs) {
var disp = (hs) ? 'none' : 'block';
for(var x = 0; x &lt; arrDiv.length; x++) {
document.getElementById(arrDiv[x]).style.display = disp;
    }

}

function chk(what, item) {
if(item) {
    visiblox(what, false);
} else {
    visiblox(what, true);
}
}
</code></pre>

<p>Calls the function:</p>

<pre><code>&lt;input type='checkbox' onclick='chk(editorial, this.checked);' checked&gt; Editorial&lt;/p&gt;
</code></pre>
