I need Java script to pass multiple checkboxes' values to the textbox?

For example:
If I check two checkboxes then I see the textbox shows two checkboxes' values separated by a comma like "coffee,beer".when I uncheck the checked checkboxes, that particular value alone should dissappear from the textbox.

```
       <form name="form1">
       <input type="checkbox" name="checkboxname" value="coffee">
       <input type="checkbox" name="checkboxname" value="tea">
       <input type="checkbox" name="checkboxname" value="beer">

         </form>

          <form name="form2">
          <input type="text" name="textname">
              </form>

```

Thank you for your help.