Welcome Guest, Not a member yet? Register   Sign In
A simple cascading drop down box
#1

[eluser]wizzer[/eluser]
Greetings,

I need to create two drop down boxes, with the choice from the first box determining the choices seen in the second box.

Are there any neat CI techniques I can use?

If not can anyone point me toward a simple tutorial. I tried one from here but i didnt quite understand it.

Javascript is really hard for me.

I have tried two tutorials so far but cannot get them to work.

Thanks in advance

Wizzer
#2

[eluser]jcavard[/eluser]
Well, first you need your two drop down controls
Code:
<select name="country" id="country">
  <option value="CAN">Canada</option>
  <option value="USA">United States</option>
</select>

<select name="states" id="states">
</select>

then add the javascript to handle the selected value
Code:
$(document).ready(function(){
  $('[name=country]').change(
    function(){
      $.post(); // post to a script that will return the data
    }
  );
});

then the php script you call outputs the value in xml format to insert into the second drop down, just use malsup's taconite, it's really simple
Code:
<replace select="#states">
  <option value="QC">Quebec</option>
  <option value="ON">Ontario</option>
</replace>
#3

[eluser]Jondolar[/eluser]
You may also want to check out some of the more popular ajax libraries (my favorite is jQuery). An ajax library may be overkill for what you are initially trying to do but it may be easier and faster.
#4

[eluser]jcavard[/eluser]
[quote author="Jondolar" date="1249951696"]You may also want to check out some of the more popular ajax libraries (my favorite is jQuery). An ajax library may be overkill for what you are initially trying to do but it may be easier and faster.[/quote]
easier.
faster.




Theme © iAndrew 2016 - Forum software by © MyBB