php - Assign an individual checkbox value as an array -
is there way of assigning value of checkbox array.
i have load of checkboxes, 1 of option. set value of array?
i have tried creating array of ints (ids) array of objects using simple loop , using print_r in value (i know bit ugly , can see why wouldn't work can't seem find correct syntax).
$arrallid = array(); foreach ($availablegroups $objasrdcallbackgroup) { $arrallid[] = $objasrdcallbackgroup->m_igroupid; } <input id="group-name" value="<?php print_r($arrallid) ?>" name="selectedgroups[]" type="checkbox">all
also design around , retrieval of collection when form posted checking if selected or know how can now..
any received.
thanks
you can use html5 data attribute store array of values. i'm not familiar php, data attribute render on client, , if checkbox clicked, can loop through array in data attribute , whatever need send data server.
<input id="group-name" data-allid="<?php print_r($arrallid) ?>" name="selectedgroups[]" type="checkbox">all function someclickhandler() { var chkgroupname = document.getelementbyid('group-name'); var allids = chkgroupname.attr('data-allid'); // need array of ids. }
Comments
Post a Comment