I am using php and JS in my code.My requirement is I need to fetch the value from my-sql database and display into drop down list dynamically.I am populating the dropdown with JS but fetching the value with php(a usual thing). So the problem I am facing is once I get the value from php code and encode it using json_encode to access that array in JS it shows me value like [object Object].
Please help.. Thanks.
Sample Code:-
<?php
$result=mysql_query("select Location from servicelist")or die (mysql_error());
while($row = mysql_fetch_array($result))
$output[]=$row;
$row=mysql_fetch_assoc($result);
$output[]=$row;
?>
<script language="javascript">
function addOption_list(selectbox){
<?php echo 'var month='.json_encode($output);?>
for (var i=0; i < month.length;++i){
addOption(document.drop_list.AreaList, month[i], month[i]);
//Once the value of the area will get selected we will call sub area based
//on the area selected from the db
}
addSubAreaList();
}