In eerste instantie heb je iets javascript achtigs nodig dat het netjes van het ene naar het andere vak veranderd. Het php controle verhaal komt daarna pas. :)
Link gekopieerd
Ergens een klein voorbeeld te vinden. Ben niet echt bekend met Java
Link gekopieerd
Link gekopieerd
Het is javascript he, dat is weer totaal anders dan java :)
Link gekopieerd
Ja dat bedoel ik. Merci voor de reacties
Link gekopieerd
Heb nu het volgende maar moet natuurlijk de keuze's meenemen naar volgende pagina maar dan met PHP. Wie heeft een idee?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ;
<html xmlns="http://
www.w3.org/1999/xhtml" ; xml:lang="en" lang="en">
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function saveMe() {
var strValues = "";
var boxLength = document.choiceForm.choiceBox.length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.choiceForm.choiceBox.options[i].value;
}
else {
strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
}
count++;
}
}
}
// End -->
</script>
</head>
<body>
<center>
<form name="choiceForm">
<select name="available" size=10 onchange="moveOver();">
<option value=1>Keuze 1
<option value=2>Keuze 2
<option value=3>Keuze 3
<option value=4>Keuze 4
<option value=5>Keuze 5
<option value=6>Keuze 6
<option value=7>Keuze 7
<option value=8>Keuze 8
<option value=9>Keuze 9
<option value=10>Keuze 10
</select>
<select multiple name="choiceBox" style="width:150;" size="10">
</select>
</center>
<br />
</form><br />
<center><input type="button" value="Verwijder" onclick="removeMe();"></center>
</body>
</html>
Link gekopieerd
Zo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options.text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function saveMe() {
var strValues = "";
var boxLength = document.choiceForm.choiceBox.length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.choiceForm.choiceBox.options[i].value;
}
else {
strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
}
count++;
}
}
}
// End -->
</script>
</head>
<body>
<center>
<form name="choiceForm" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p>
<input type="submit" value="verzenden" />
</p>
<select name="available" size=10 onchange="moveOver();">
<option value=1>Keuze 1
<option value=2>Keuze 2
<option value=3>Keuze 3
<option value=4>Keuze 4
<option value=5>Keuze 5
<option value=6>Keuze 6
<option value=7>Keuze 7
<option value=8>Keuze 8
<option value=9>Keuze 9
<option value=10>Keuze 10
</select>
<select multiple id="choiceBox" name="choiceBox[]" style="width:150;" size="10">
</select>
</center>
<br />
</form><br />
<center><input type="button" value="Verwijder" onclick="removeMe();"></center>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<pre>' . print_r ($_POST, true) . '</pre>';
}
?>
</body>
</html>
Link gekopieerd
Merci Jan maar geprbeerd en doet het niet. Kan de pagina niet vinden i.p.v printen
Link gekopieerd
Zou je nog eens kunnen kijken Jan? $_SERVER['REQUEST_URI'] ken ik trouwens niet.
Bumpen:
Twee of meer keer achter elkaar in een topic posten heet bumpen. Bumpen is pas na 24 uur toegestaan en kan een reden zijn voor de admins en moderators om een topic te sluiten. Gebruik indien nodig de knop om je tekst aan te passen.
Link gekopieerd
Link gekopieerd