Selecting groups of options in selectbox

Selecting groups of options in selectbox

I'm trying to create a selectbox where when you select certain options in the selectbox, it automatically selects a group of options in the same selectbox. So lets say we had a selectbox with these options:
 
fruit
apple
banana
pear
animals
monkey
elephant
kangaroo
 
I would like to make it to where if the user selected "fruit" as an option, apple, banana and pear would automatically get selected also and if htey chose "animals", all the animals would also get selected. Any ideas?