I can't find out how to post the form/listboxes so I can use it on the next page! This is the first time I post on this forum so I hope my script is readable...
And yes, the code is meshed up but that's for later..
Hope someone can help me!
<?php
//require_once 'include.inc.php';
if(isset($_POST['submit'])){
echo "Here should the list of members (right column) be printed!";
}
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
function moveOver() {
var boxLength = document.usergroup.members.length;
var selectedItem = document.usergroup.users.selectedIndex;
var selectedText = document.usergroup.users.options[selectedItem].text;
var selectedValue = document.usergroup.users.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.usergroup.members.options.text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.usergroup.members.options[boxLength] = newoption;
}
document.usergroup.users.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.usergroup.members.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.usergroup.members.options.selected) {
arrSelected[count] = document.usergroup.members.options.value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.usergroup.members.options.value == arrSelected[x]) {
document.usergroup.members.options = null;
}
}
boxLength = document.usergroup.members.length;
}
}
// -->
</script>
<?php
//$result1 = querydb("SELECT userID, firstName FROM user");
//$result2 = querydb('SELECT user.userID, firstName FROM user, user_group WHERE user.userID = user_group.userID and user_group.groupID = "1"');
?>
<form name="usergroup" method="post" action="test3.php">
<table>
<tr>
<td>Users:</td>
<td>Groupmembers:</td>
</tr>
<tr>
<td>
<select name="users" size=10 onchange="moveOver();">
<?php
//for($i=0; $i<count($result1); $i++){
//echo('<option value='.$result1[$i]->userID.'>'.$result1[$i]->firstName.'</option>');
//}
echo ('<option value="piet">Piet</option>');
echo ('<option value="jan">Jan</option>');
echo ('<option value="klaas">Klaas</option>');
echo ('<option value="rene">Rene</option>');
echo ('<option value="gerrit">Gerrit</option>');
echo ('<option value="dirk">Dirk</option>');
?>
</select>
</td>
<td>
<select multiple name="members" style="width:150;" size="10" onchange="removeMe();">
<?php
//for($i=0; $i<count($result2); $i++){
//echo('<option value='.$result2[$i]->userID.'>'.$result2[$i]->firstName.'</option>');
//}
echo ('<option value="piet">Piet</option>');
echo ('<option value="jan">Jan</option>');
echo ('<option value="klaas">Klaas</option>');
?>
</select>
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value=" OK "></td>
</tr>
</form>