CodeIgniter Forums
casecade dropdown - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: casecade dropdown (/thread-23190.html)



casecade dropdown - El Forum - 10-03-2009

[eluser]Unknown[/eluser]
hai everybody

I want to load a selectbox based on another selectbox selected value. For example load state selectbox based on selected country. can anyone help me, its is very urgent for me.



thanks before


casecade dropdown - El Forum - 10-04-2009

[eluser]AlexPOWER[/eluser]
do you use dynamic or static select box?


casecade dropdown - El Forum - 10-04-2009

[eluser]Unknown[/eluser]
Thanks for the reply.

I use dynamic selectbox. For that i used this code,


<select id="country">ajax->remote_function(array('update' => 'state', 'url' => "/test/index.php/test/testfun/"); ?&gt;">
<option value="1">India</option>
<option value="2">Australia</option>
</select>

<select id="state">

</select>



This function work properly, but i dont know how to get and pass the country id to testfun function.


casecade dropdown - El Forum - 10-05-2009

[eluser]AlexPOWER[/eluser]
Ok,
try with this.

Code:
function reload(form){
var val=form.cuntry.options[form.cuntry.options.selectedIndex].value;
self.location=index.php?cuntry=' + val;
}
and just add input function like...
Code:
&lt;?
@$cuntry = $_GET['cuntry'];

if(strlen($cuntry) > 0 and !is_numeric($cuntry))
{
    echo "Data Error 2";
    exit;
}
?&gt;

That may help! 8-/

So you have $cuntry as a number,and you can manipulate with it!