Dropdown from database |
[eluser]Kentus[/eluser]
Hi everyone, i need some help in this problem: i have a dropdown select with 7 values. i have another dropdown where i suppose to show in each option a value from database where name="precedent dropdown value selected". i have this code: Code: <div id="reg_text"> Thanks for future advices.
[eluser]Wondering Coder[/eluser]
in my controller Code: $data['elem'] = $this->dataset_db->getElementary(); in my view Code: <select name="elem" class="searchIndustry">
[eluser]Kentus[/eluser]
My db structure: name, arm_one,arm_two,arm_three,power. My first row: Mario, spear, arc, sword,20 Second row: John, knife, double sword, double axes, 30 My view: a select where you can choose between Mario and John. another select where i must show arm_one, arm_two, arm_three contents for Mario if previously select is on Mario (that means: option one: spear, option two: arc, option three: sword) or if John is selected (option one: knife, option two: double sword, option three: double axes). Wondering Coder thanks for trying helping me.
[eluser]theprodigy[/eluser]
Basically, what you want to do is set a onchange attribute on the first select box (or set a javascript listener), and have it do an ajax call to get the options for the next select drop down.
[eluser]Kentus[/eluser]
i found a method but isn't very good i think: i set a onchange attribute but i use this code in [removed] Code: var abc="http://89.41.129.47/earthwar" i don't use ajax until now. i search on google but i have some questions: i need asp server?
[eluser]theprodigy[/eluser]
Quote:i don’t use ajax until now. i search on google but i have some questions: i need asp server?No, you don't need an ASP server. Ajax is nothing more than javascript that makes a call to your server (either post or get), and can retrieve content based on the response of that call. It does it without doing a page refresh. There are many prebuilt ajax objects out there that you can use (most common is part of jQuery), but I would strongly suggest learning about it before using it. One quick google search for "ajax tutorial php", brought up several sites, including this one from tizag To use ajax with jQuery, their docs are http://api.jquery.com/jQuery.ajax/ |
Welcome Guest, Not a member yet? Register Sign In |