Hi,
I'm creating a page to add users to active directory. I have made a custom scrollable checkbox list (see http://c82.net/article.php?ID=25) and have adapted my code so that the User Groups get imported into that list. What i want, is to get the selected groups in an array and post that to the next page (it's all within a form). But the array gets filled like this: Array ( [0] => on [1] => on [2] => on [3] => on )
Pieces of my code:
CSS stuff:
.checklist {
border: 1px solid #ccc;
list-style: none;
height: 10em;
overflow: auto;
width: 25em;
}
.checklist, .checklist li { margin: 0; padding: 0; }
.checklist label {
display: block;
height: 15%;
padding-left: 25px;
text-indent: -25px;
}
.checklist label:hover { background: #777; color: #fff; }
Javascript stuff:
var form='mainform'
function SetChecked(val,chkName) {
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements[i].name==chkName) {
dml.elements[i].checked=val;
}
}
}
function initChecklist() {
if (document.all && document.getElementById) {
// Get all unordered lists
var lists = document.getElementsByTagName("ul");
for (i = 0; i < lists.length; i++) {
var theList = lists[i];
// Only work with those having the class "checklist"
if (theList.className.indexOf("checklist") > -1) {
var labels = theList.getElementsByTagName("label");
// Assign event handlers to labels within
for (var j = 0; j < labels.length; j++) {
var theLabel = labels[j];
theLabel.onmouseover = function() { this.className += " hover"; };
theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
}
}
}
}
}
And the php piece:
if ($entries["count"] > 0) {
print "<ul class=\"checklist\">";
for ($i=0; $i<$entries["count"]; $i++) {
echo "<li><label for=\"".$entries[$i]["dn"]."\"><input id=\"".$entries[$i]["dn"]."\" name=\"selgroups[]\" type=\"checkbox\"> ".$entries[$i]["cn"][0]." </label></li>";
}
print "</ul><br>";
} else {
echo "<li>Error: no Groups found!?</li>";
print "</ul><br>";
}
print "<a href=\"javascript:SetChecked(0,'selgroups[]')\">Clear</a><br>";
And i want the array to be filled with the $entries[$i]["dn"] value.
Anyone? 🙂
kind regards,
errtu