我有很多复选框。我想将它们的值放入逗号分隔的数组中。如果复选框被取消选中,则值将为空,因此:
酒吧,停车场,,,,,电视等
我该怎么做?制作数组后,我将提交到数据库中。
<p>
<label for="meta_box_check_bar">bar</label>
<input type="checkbox" id="meta_box_check_bar" name="meta_box_check_bar" value="bar" />
<label for="meta_box_check_parking">parking</label>
<input type="checkbox" id="meta_box_check_parking" name="meta_box_check_parking" value="parking" />
<label for="">accessible-for-disabled</label>
<input type="checkbox" id="meta_box_check_accessible-for-disabled" name="meta_box_check_accessible-for-disabled" value="accessible-for-disabled" />
<label for="">air-conditioning</label>
<input type="checkbox" id="meta_box_check_air-conditioning" name="meta_box_check_air-conditioning" value="air-conditioning" />
<label for="">frigobar </label>
<input type="checkbox" id="meta_box_check_frigobar" name="meta_box_check_frigobar" value="frigobar" />
<label for="">pets</label>
<input type="checkbox" id="meta_box_check_pets" name="meta_box_check_pets" value="pets" />
<label for="">phone</label>
<input type="checkbox" id="meta_box_check_phone" name="meta_box_check_phone" value="phone" />
<label for="">tv</label>
<input type="checkbox" id="meta_box_check_tv" name="meta_box_check_tv" value="tv" />
<label for="">typical-local-dishes</label>
<input type="checkbox" id="meta_box_check_typical-local-dishes" name="meta_box_check_typical-local-dishes" value="typical-local-dishes" />
</p>