Please have a carefull look of my code. I am trying to differentiate the items after the final submission so that I have all items for each submission togather and those item must be identified whether it comes from top menu or the bottom menu.
Suppose user chose 2 and then press submit. Now for first time user chose January and March from the top menu and March from the bottom menu and hit submit. Now in second time user select April from Bootm Menu and hit submit. After getting the output items from all submission I want to store those in a MYSQL Database. The order of the selected items for each submission is also important.
Expected output:
First time: January(1) from Top Menu.
March(2) from Top Menu.
March(3) From Bottom Menu.
Second Time: April(1) from Bottom Menu
Please let me know if you have some idea how to do that. Thank you.
<html>
<title>
Menu test
</title>
<body>
<script type="text/javascript">
<!--
function updateTextBox(selectObj, textBoxObj)
{
var index = selectObj.selectedIndex;
var selection = selectObj.options[index].text;
textBoxObj.value += selection + "\n";
}
// -->
</script>
<!-- <form name = "myform" action="CheckInsertedItems.php" method="POST"> -->
<pre>
<?php
extract( $_GET );
if( !isset($submit))// do this if no GET vars
{
print "<form method=\"GET\">";
print "<p>Enter in the number of times below:</p>";
print "<input type=\"text\" name=\"number\" size=\"30\">";
$menu_counter = 0;
print "<input type='hidden' name='menu_counter' value=$menu_counter>";
print "<input name=\"submit\" type=\"submit\" value=\"send\">";
print "<input name=\"reset\" type=\"reset\" value=\"reset\">";
print "</form>" ;
}
else
{
if( $submit=='submit' )
{
$results[] = $currentSelections;
}
if( $number>0 )
{
$months = array("January","February","March","April","May","June","July", "August","September","October","November","December");
$number = $HTTP_GET_VARS["number"]-1;
$menu_counter =$HTTP_GET_VARS["menu_counter"]+1;
print "<form method=\"GET\">";
print "Select components for term $menu_counter<br>";
?>
<select size="5" name="user_choice[]" onclick="updateTextBox(this, currentSelections)">
<?php
foreach ($months as $Existing_Item)
{
print "<option value=\"$Existing_Item \">$Existing_Item</option>";
}
print "</select>";
print "<br>";
?>
<select size="5" name="user_choice[]" onclick="updateTextBox(this, currentSelections)">
<?php
foreach ($months as $Existing_Item)
{
print "<option value=\"$Existing_Item \">$Existing_Item</option>";
}
print "</select>";
print "<br>";
?>
<textarea name = 'currentSelections' readonly="readonly" rows = "3" cols = "20"></textarea>
<br>
<?php
print "<input type='hidden' name='number' value=$number>";
print "<input type='hidden' name='menu_counter' value=$menu_counter>";
print "<input name=\"submit\" type=\"submit\" value=\"submit\">";
print "<input name=\"reset\" type=\"reset\" value=\"reset\">";
$i=0;
if( isarray( $results ) )
foreach( $results as $res )
{
echo "<input type='hidden' name='results[$i]' value='$res'>";
$i++;
}
print "</form>";
}
else
{
print "<br>You choice are: <br>";
$Selected_Array = $results;
foreach($Selected_Array as $name)
{
print "$name<BR>";
}
}
}
?>
</body>
</html>