accessing php array in js using json_encode
<p>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].</p>

<p>Please help..
Thanks.</p>

<p>Sample Code:-</p>

<pre><code>&lt;?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;

 ?&gt;
&lt;script language="javascript"&gt;
function addOption_list(selectbox){
&lt;?php echo 'var month='.json_encode($output);?&gt;

for (var i=0; i &lt; 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();
}
</code></pre>
