can't post form with listbox with javascript

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

03/03/2004 14:32:00
Quote Anchor link
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!

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<?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>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
<?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();">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?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();">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
<?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>
 
PHP hulp

PHP hulp

25/11/2024 12:23:27
 
Rick

Rick

03/03/2004 15:20:00
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
<?
echo '<pre>';
print_r($_POST);
echo '</pre>';
?>
 

03/03/2004 15:22:00
Quote Anchor link
en dan?? Het probleem is juist dat die waardes niet in $_POST zitten...... :S
 
Mitch X

Mitch X

03/03/2004 15:38:00
Quote Anchor link
Sins when doe wie poost questions in English?
Isn't tis a Duts forum :)
 

03/03/2004 15:44:00
Quote Anchor link
Vertaling voor Mitch:

Het lukt me niet het form/de listbox te posten zodat ik het op de volgende pagina kan gebruiken. Dit is de eerste keer dat ik iets op dit forum post dus ik hoop dat m'n script leesbaar is. En ja, de code is een zooitje maar dat komt later wel.
Hoop dat iemand me kan helpen!
----
Nu graag je oplossing Mitch!
 
Mitch X

Mitch X

03/03/2004 15:50:00
Quote Anchor link
Doe het gewoon met PHP :)

if($_POST[submit])
{
// actie
}
else
{
// formuliertje met listboxes :)
}
 
Peanuts

peanuts

03/03/2004 16:41:00
Quote Anchor link
The problem you're having is with the usage of multiple select boxes

If you want the values of the multiple select boxes you need to have them highlighted (selected)...

It kind off comes with the name ;)

this you have to fix in javascript.. here's how (first let me do the dutch aswell)

Het probleem ligt in het gebruik van Multiple select boxen .. alleen die waarden die geselecteerd zijn worden doorgegeven ... met javascript moet je dus eerst alle waardes selecteren...
het javascriptje

function selectall()
{
var o = document.combo_box['FIELDNAME[]'].options
for (var i = 0; i < o.length; i++)
{
var optie = o;
optie.selected = true;
}
}

greets en mvg

Peanuts
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.