Chained DropDownLists |
[eluser]GabrieleMartino[/eluser]
I have, lets say 2 DropDownList, which i visualize in a page. The value of the 2 DropDownList comes from the same db of the kind column1, column2. I would like that when a value in column1 is selected from DropDownList1, it display on DropDownList2 all the corresponding value of column2. I know how to perform the querys in the model but i don't know how to refresh the dropdownlist2 each time column1 is selected. Any suggestion would be appreciate.
[eluser]PhilTem[/eluser]
You need to somehow submit the form in order to get the selected dropdown1-item. If you do this with an Code: onChange="this.form.submit();"
[eluser]jojo777[/eluser]
Sorry i'm not english native but if i'm not wrong you are asking about 2 dependent select list. I had that problem in a project. It was about Island and City. I finally did it with jQuery/AJAX. Try this. Code: $(document).ready(function(){ So wen you choose an option in option list number 1 you will launch load_select2(). Its like this. Code: function load_select2(callback){ And in your controller Code: function your_load_optionlist_function() So your view is simple foreach inside an option tag... Code: <option value="-1">SELECT</option> Hope it helps dude! Maybe there are other options to do this, but this one worked for me.
[eluser]GabrieleMartino[/eluser]
I prepared the model the controller and the view. I tryed with ajax. But the success function is not invoked. I'm sure the path of url is correct. What can be. I followed this thread... http://ellislab.com/forums/viewthread/199987/
[eluser]jojo777[/eluser]
[quote author="GabrieleMartino" date="1351166731"]I prepared the model the controller and the view. I tryed with ajax. But the success function is not invoked. I'm sure the path of url is correct. What can be. I followed this thread... http://ellislab.com/forums/viewthread/199987/[/quote] It shoul work with the above code i wrote. Post more info.
[eluser]GabrieleMartino[/eluser]
My Model Code: <?php My controller Code: <?php My View Code: <?php echo form_open('pages/home'); ?>
[eluser]GabrieleMartino[/eluser]
I tried to add also Code: dataType: "json", in $.ajax( ...)
[eluser]jojo777[/eluser]
Did you try my code? Give some time I'll try see your code in a few
[eluser]GabrieleMartino[/eluser]
[quote author="jojo777" date="1351169120"]Did you try my code? Give some time I'll try see your code in a few[/quote] I'm trying to get how to work with your code.
[eluser]GabrieleMartino[/eluser]
I don't understand how the msg variable is returned. |
Welcome Guest, Not a member yet? Register Sign In |