A form I'm working on requires an option box which concatenates variables from a 2 dimensional array into the select area. When a user selects from the list, I need to hold onto only the second part of the concatenation (Vopt[x][2]). In my example below, I'm trying to trap the value in Topt. If you paste the code below as 'option.php', maybe you can tell me where I've bonked.
Thanks - Keith
Code:
<html>
<head>
<title>Option Menu</title>
</head>
<body>
<?php
$Vopt[0][1]="I" ;
$Vopt[0][2]="0,2" ;
$Vopt[1][1]="You" ;
$Vopt[1][2]="1,2" ;
$Vopt[2][1]="He/She/It" ;
$Vopt[2][2]="2,2" ;
$Vopt[3][1]="We" ;
$Vopt[3][2]="3,2" ;
$Vopt[4][1]="All You all" ;
$Vopt[4][2]="4,2" ;
$Vopt[5][1]="They" ;
$Vopt[5][2]="5,2" ;
Echo "<br> OPT: ".$_POST[opt]."<br>\n" ;
Echo "<br> TOPT: ".$_POST[topt]."<br>\n" ;
?>
<form action="option.php" method="POST">
<Select Name="opt">
<?php
for ($i = 0; $i <6; $i++)
{
if ( $_POST[opt] == $Vopt[$i][1]." - ".$Vopt[$i][2] )
{
echo "<option selected>", $Vopt[$i][1]." - ".$Vopt[$i][2], "</option>\n";
echo "<input type='hidden' name='topt' value=".'"'.$Vopt[$i][2].'"'.">\n";
}
else
{
echo "<option>", $Vopt[$i][1]." - ".$Vopt[$i][2], "</option>\n";
echo "<input type='hidden' name='opt' value=".'"'.$Vopt[$i][2].'"'.">\n";
}
}
?>
</select>
<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE="Display">
</FORM>
</body>
</html>
Thanks - Keith