I have a page which allows a user to add items to a listbox. When the form submits I want to capture all values from the listbox on a second page as an array so that I can save them to a table. I am currently using the request method however I am only capturing one of the values from the list box and can't seem to find any examples on how to proceed. Any help will be appreciated.
Thank you,
Josh
The code for the two files is as follows:
file: test1.php
<HTML>
<HEAD>
<TITLE>SDLC Input</TITLE>
<script language="JavaScript">
function AddItems()
{
var myForm = document.Form1; //Form Name
var mySel = myForm.sel1; // Listbox Name
var myOption;
myOption = document.createElement("Option");
myOption.text = document.getElementById("project_number").value; //Textbox's value
myOption.value = document.getElementById("project_number").value; //Textbox's value
mySel.add(myOption);
}
// begin list clear
function clearlistbox(lb)
{
for (var i=lb.options.length-1; i>=0; i--)
{
lb.options = null;
}
lb.selectedIndex = -1;
}
</script>
</HEAD>
<body>
<FORM name="Form1" METHOD="POST" ACTION="test2.php">
<center><h3>Project Checklist</h3>
<hr>
</center>
<? // Project Number ?>
<tr><td>
<b>Project Number:</b>
</td><td>
<input type="text" size=6 id="project_number" name="project_number" value="" >
<align="center" valign="middle">
<input type="button" value="Add"
onclick="AddItems()">
<input type="button" value="Clear"
onclick="clearlistbox(sel1)" />
<select name="sel1" id="sel1" size="5" multiple="multiple" >
</select>
<a href=javascript:launchwin('proj_numbers.htm','Project_Numbers','height=300,width=600,scrollbars,resizable')>Project Codes</a>
</td></tr>
</table>
<center><INPUT TYPE=SUBMIT VALUE='<<<<<< SAVE >>>>>>>'></center>
</BODY>
</HTML>
file: test2.php
<?php
$sel1 = trim($_REQUEST['sel1']);
echo $sel1;
?>