robinrl2008
asked on
Syntax Correction for Drop Down List Selection
I have generated a drop down list with php but I can't seem to set the selected value. Could someone please correct my mistake.
I have attached the code.
Thanks
I have attached the code.
Thanks
$dataset = array("January","February","March","April","May","June","July","August","September","October","November","December");
$test = "January";
echo "<select name=vendorddl>";
echo "<option value="."---".">"."---"."</option>";
$numberofrecords = count($dataset);
for ($x=0; $x<$numberofrecords; $x++)
{
$selected = $test;
$lbvalue = $dataset[$x];
echo "<option value=".$lbvalue."selected="."'".$selected."'".">".$lbvalue."</option>";
}
echo "</select>";// Closing of list box
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER