multiple checkbox values

multiple checkbox values

Hi i have checkboxes in the below format,

<input type="checkbox" name="all">
<input type="checkbox" name="all_a">
<input type="checkbox" name="a1" value="1">
<input type="checkbox" name="a2" value="2">

<input type="checkbox" name="all_b">
<input type="checkbox" name="b1" value="3">
<input type="checkbox" name="b2" value="4">

<input type="checkbox" name="all_c">
<input type="checkbox" name="c1" value="5">
<input type="checkbox" name="c2" value="6">

<input type="checkbox" name="all_d">
<input type="checkbox" name="d1" value="7">
<input type="checkbox" name="d2" value="8">

<textarea name="checkbox_val"> </textarea>

Which ever checkbox i check that value should be shown in textarea, if i uncheck or check another checkbox it should be reflected in the textarea.

if i check checkbox all, all the checkbox should be checked and also the checkbox values should be shown in textarea,

Similarly, if i check all_a only a1 and a2 should be checked.  Same thing applies for b,c,d as well.

Can someone tell me how to do the above thing. 

Thanks