Forum Moderators: coopster
<INPUT onclick=selectAll(document.combo_box.right box) name=rbox; type=submit value=Submit name=submit_button>
It had to basically select all the values in the right box in order for the formmail script to mail me the values.
I want to use the same selection process in my PHP form but can't for the life of me figure out how to do the same thing.
name attribute of the <select> tag:
<select name="my_list[]" multiple="multiple" size="10">
Submitform.php
<form action="confirmform.php" method="POST">
<select style="WIDTH: 250px" multiple size=20 name=list1>
<option value="Player 1">1</option>
<option value="Player 2">2</option>
</select>
<INPUT id=button2 onclick=move(this.form.list1,this.form.team) type=button value=">>" name=button2>
<INPUT id=button1 onclick=move(this.form.team,this.form.list1) type=button value="<<" name=button1>
<select name="team[]" size=10 multiple="multiple" id=team style="WIDTH: 250px">
</SELECT>
<input type=submit value=Submit name=submit_button>
<input name="Go" type="submit" id="Submit" value="Go" />
</form>
And then the confirmform.php
<form action=submitted.php method=post>
Info - <?php echo $_POST["team[]"];?>
<?php foreach ("team[]" as $selection) { echo $selection . '<br />'; }?>
<input type=button value="Go Back" onClick="history.go(-1)">
<input name="That's Right" type="submit" id="Submit" value="That's Right" />
[edited by: jatar_k at 5:59 pm (utc) on Jan. 22, 2004]
[edit reason] trimmed down to relevant code [/edit]
Info - <?php echo $_POST["team[]"];?></strong></span><br />
</p><?php foreach ("team[]" as $selection) { echo $selection . '<br />'; }?>
</p>
Info - <?php echo $_POST['team'];?></strong></span><br />
</p><?php foreach ($_POST['team'] as $selection) { echo $selection . '<br />'; }?>
</p>
Note the highlight where the changes occur.
My sample code did not refer to the variable through the $_POST super global. Also, you don't need the empty [] on the team variable when extracting values from the array. You may want to study arrays in the php [php.net] documentation.
did you try the code on your own? i really have no idea what's wrong. i've stripped off just about everything and here is what i have left:
submitform.php =
<form action="confirmform.php" method="POST">
<select style="WIDTH: 250px" multiple size=20 name=list1>
<option value="1">1</option>
<option value="2">2</option>
</select>
<INPUT id=button2 onclick=move(this.form.list1,this.form.team) type=button value=">>" name=button2>
<INPUT id=button1 onclick=move(this.form.team,this.form.list1) type=button value="<<" name=button1>
<select name="team[]" size=10 multiple="yes" id=team style="WIDTH: 250px">
</SELECT>
<INPUT type=submit value=Submit name=submit_button>
</form>
and confirmform.php =
<?php foreach ($_POST['team'] as $selection) { echo $selection . '<br />'; }?> </p>
It's got to have something to do with the 'team' box not having any values in it to begin with, and then getting some from the 'list1' box?
[edited by: jatar_k at 3:54 am (utc) on Jan. 23, 2004]
[edit reason] way too much code [/edit]
[validator.w3.org...]
there are more than a few problems in there that won't make your life any easier. The triple body tag being one. These may change behaviours or cause other errors that may only serve to confuse you.
and congrats on figuring it out :)