Click to See Complete Forum and Search --> : Problem with storeing data after a loop of submission


szms
08-12-2003, 01:17 PM
Hi there! Please have a look of my code. I am teying to select some items from two menu using java script and then showing those in a text box. Then user will submit. This process can go "n" times. and then I want to store all data that has been submitted. But some how I am getting my array works properly, I guess. Could you please help me? 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"> -->
<?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( $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


--- Here I am trying to store the selected data ----
//$Selected_Array[] = $currentSelections;

print "<input type='hidden' name='Selected_Array[]' value=$currentSelections>";





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\">";
print "</form>";
}
else
{
// do whatever happens after the number of forms has been filled




--- Here I am trying to show all selected data ----
print "<br>You choice are: <br>";
$Selected_Array = $HTTP_GET_VARS["Selected_Array"];
foreach($Selected_Array as $name)
{
print "$name";
}


}
}

?>
</body>
</html>