PDA

View Full Version : Problem with multiple menu showing one at a time and select item from the menu.


szms
Mon 11th Aug '03, 11:03am
Please take a llok of my code. after hitting the second submit button it supposed to show me "You choosed ................"

Please help me with this code.


<?php
$Function_Name[] = "foo";
$Function_Name[] = "bar";
$Function_Name[] = "foobar";
$Function_Name[] = "barfoo";
$Function_Name[] = "kittythrow";
?>
<pre>
<form method="POST">
<b>How many times you want</b>
<input type="text" name="number" Size = "30">
<?php
if(isset($_POST['submit'])) {
?>
<b>Select any of the following Function</b>
<?php
for ($i=0; $i<$_POST['number']; $i++) {
echo '<select name="FunctionMenu'.$i.'">';
foreach ($Function_Name as $Existing_Function) {
echo "<option value=\"$Existing_Function \">$Existing_Function</option>";
}
echo "</select>\n";
}
}
?>
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="Reset">
</form>
<?php
if(isset($_POST['FunctionMenu'])) {
echo 'You choosed '.$_POST['FunctionMenu'].'!';
}
?>

szms
Mon 11th Aug '03, 2:20pm
I tried the following code but still cannot solve the problem.Could you please teake a look of this peace od code and give me some feedback. Thank you.

<?
$Function_Name[] = "foo";
$Function_Name[] = "bar";
$Function_Name[] = "foobar";
$Function_Name[] = "barfoo";
$Function_Name[] = "kittythrow";

print "<form action=\"menutest3.php\" method=\"get\">";
print "<b>How many times you want?</b><br>";
print "<input type=\"text\" name=\"how_many\" value=\"$how_many\" Size =\"30\">";
print "<input type=\"submit\" value=\"Submit\" name=\"submit\">";
print "<input type=\"reset\" value=\"Reset\" name=\"Reset\">";
$num = 0;
if($submit=="Submit")
{

while(($num < $how_many))
{
echo '<select name="FunctionMenu">';
foreach ($Function_Name as $Existing_Function)
{
echo "<option value=\"$Existing_Function \">$Existing_Function</option>";
}
echo "</select>\n";
print "<input type=\"submit\" value=\"View\" name=\"submit\">";
print "<input type=\"reset\" value=\"Reset\" name=\"Reset\">";
print "</form>";
$num++;
}
}
if(($submit=="View"))
{
echo 'You choosed '.$_POST['FunctionMenu'].'!';
}
?>