[eluser]ELRafael[/eluser]
You didn't call the js function on the first dropdown. Try to put in the drowpdown something like this
Code:
<!-- put onchange below. the ci forum didn't show what i wrote :( -->
<select name="Project_ID" id="Project_ID">
</select>
You can try use JQuery, I think its a little better. An example:
Code:
[removed]
// <![CDATA[
$(document).ready(function() {
$("select[@name=states]").change(function() {
$("select[@name=city]").html('<option>Searching...</option>');
$.post(base_url+'search_city', { uf: $(this).val() }, function (retorno) {
$("select[@name=city]").html(retorno);
});
});
});
// ]]>
[removed]
//The view
<select name="states" id="states">
<option value="0" selected="selected">Selecione um estado</option>
<?php foreach($states->result() as $state) : ?>
<option value="<?php echo $state->id; ?>"><?php echo $state->name; ?></option>
<?php endforeach; ?>
</select>
<select name="city" id="city">
</select>
In this case, every time that select with name states changed, will pass by post (you can change to get) to method search_city the var uf. This var have the id value. In the search_city method you return something like this
Code:
echo '<option value="'.$city_id.'">'.$city_name.'</option>';