Hi,

I'm building an ajax/php/mysql application.
I have 3 dependent dropdowns. I use ajax to avoid the page reload on every selectbox change.

But if I reload the page after I drill down the 3 dropdowns, only the first dropdown maintains it's selected option, because I did it with php.

But I'm trying to do it for the 2nd and 3rd dropdown with javascript:

<code>
$marca = $_GET['IDMarca'];
echo "obj.options[obj.options.length] = new Option('-Seleccione-','0');\n";
while($resmodelo = mssql_fetch_array($queryModelos))
{
echo "obj.options[obj.options.length] = new Option('".$resmodelo['Descricao']."','".$resmodelo['IDModelo']."');\n";
echo "for (var i=0; i < obj.options.length; i++) {\n";
echo "alert('obj.options[i].selectedIndex.Value');";
echo " if (obj.options[i].selectedIndex.Value = ".$marca.") {\n";
echo " obj.options[i].selected = true;}\n";
echo "}\n";
}
</code>

But... it's not working. I get the error:
Error: obj.options[i].selectedIndex has no properties

Please help.

Mário