I have a registration form on RSForm component.
One of the fields is Estado (state). It is a dropdown populated with content that comes from a mysql table, where i use some code like that:
$items = "|Selecione um estado";
$db =& JFactory::getDBO();
$db->setQuery("SELECT id_state, name_state FROM table_states ORDER BY name_state");
$result = $db->loadObjectList();
foreach ($result as $r)
$items .= "\n" . $r->id_state . '|' . $r->name_state;
There is another field which is a dropdown too, called Cidade (city). It must be filled according to what's selected by previous field (Estado). It must consult a mysql table too. The logic maybe something like that:
"SELECT id_city, id_from_state, name_city FROM table_cities ORDER BY name_city WHERE id_from_state='$some_var_id_state' "
Actually, my tests are on this page: [url removed, login to view]
It is kind of simple. But i'm not able to do it.
P.S.: I really NEED to make this form using RSForm and using mysql queries.
2 freelancers are bidding on average $45 for this job
Your problem can easily be solved and will not take long at all. We may need to change the structure of the City table in your database. I have developed numerous similar drop downs previously.