Link to home
Start Free TrialLog in
Avatar of robinrl2008
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
$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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robinrl2008
robinrl2008

ASKER

Thanks, I really love this site it makes my work much easier and less time consuming. You Rock!!