views:

534

answers:

1

Hello,

I can manage to get values from mysql using select box in php, but i can't make it with two-level chained select box.

Anyone have some example code or idea for that?

Thanks.

+1  A: 

You're trying to handle clientside stuff, so you'll need to do this with javascript.

<input type="checkbox" name="chck_1" id="chck_1" onclick="javascript:setValue('chck_2');"/> Checkbox 1
<input type="checkbox" name="chck_2" id="chck_2"> Checkbox 2

In javascript you create a function:

function setValue(element)
{
  var fieldElement = document.getElementById(element);
  if(fieldElement.checked)
  {
    fieldElement.checked = false;
  }
  else
  {
    fieldElement.checked = true;
  }
}

I haven't tested the code, but it should do ;)

Edit I've misread your post, but a similar thing can be done by setting it to selectboxes, only then you can fill it with the correct data when the first selctbox is selected to a specified index or something.

Ben Fransen