How would I convert a json string that contains checkbox values to a list?
For example, I have the following json string : {"User1":"Checked","User2":"","User3":"Checked"}
I want to pull a list from the above data, and assign it to a variable. The list should of course, only output the checked elements as such :
User1 User3
and ignore the unchecked items.
Is this possible?
Original thought was to do this in a jqgrid layout, original question here : https://stackoverflow.com/questions/34615244/best-way-to-do-jqgrid-with-json-strings
Full Array Code(processing side) :
$status = $data['data-invoice-status']; // this is an array
$status_array = array(); // create new array
$status_names = array(1 => "Service Call",2 => "Estimate",3 => "Bid Accepted",4 => "Unstaged",5 => "Staged",6 => "Assigned",7 => "In Progress",8 => "Job Complete",9 => "Billed");
for($i = 1; $i <= 9; $i++){ // loop from 1 to 5
if(in_array($i, $status)){ // if value exists (has been selected), stack 'checked', if not, stack ''.
$status_array[$status_names[$i]] = "checked";
} else {
$status_array[$status_names[$i]] = "";
}
}
$status_json = mysqli_real_escape_string($this->_con, json_encode($status_array)); // encode the array into JSON and then escape it.
I then save $statusd into my db whenever anyone updates the form, but no data is transferred.