Title: Get Checkbox value from EditForm modal dialog in Basic CRUD application Post by: andyj on May 26, 2014, 02:25:41 AM I have a datagrid with a pop-up modal dialog to update and insert records based on the Basic CRUD Application in the demo.
On my dialog form I have a checkbox field. The corresponding database field is a MySQL tinyint which is 0=false and 1=true. This numeric value has to be converted from and into the form's checkbox.prop('checked',false) or checkbox.prop('checked',true). To set the value before opening the dialog, I code as follows ("IsActive" is my checkbox field = 1 or 0): Code: function editRecord(){ THIS IS WHAT DOESN'T WORK AND I CAN'T WORK OUT WHY. Translating the checkbox property back to a 1 or 0 when submitting the popup dialog edit form Code: function updateRecord(){ Code: if ($('#idformIsActive').prop('checked') == true) { What happens when the else clause fires (checkbox is unchecked) is:
It's like this clause is failing when it shouldn't Code: if (result.success){ Any ideas? Thanks for your insights! Title: Re: Get Checkbox value from EditForm modal dialog in Basic CRUD application Post by: stworthy on May 26, 2014, 03:38:33 AM What does 'data_update.php?class_id='+row.id return? You can show it out in 'success' function when submitting the form.
Code: $('#fm').form('submit',{ Title: Re: Get Checkbox value from EditForm modal dialog in Basic CRUD application Post by: andyj on May 26, 2014, 07:34:39 AM In the developer console it says;
Notice: Undefined index: IsActive in /volume1/web/govportal/app/committee2/data_update.php on line 5 {"success":true} Uncaught SyntaxError: Unexpected token : committee.php:107 $.form.success committee.php:107 cb jquery.easyui.min.js:6091 x.event.dispatch jquery.min.js:5 y.handle line 5 in data_update.php Code: $IsActive = $_REQUEST['IsActive']; Code: <?php lines 106 and 107 in calling file: Code: return $(this).form('validate'); Title: Re: Get Checkbox value from EditForm modal dialog in Basic CRUD application Post by: stworthy on May 26, 2014, 08:14:03 AM Some errors occur in your 'data_update.php' file. You need to verify if a variable is set before using it.
Code: $IsActive = isset($_REQUEST['IsActive']) ? $_REQUEST['IsActive'] : 0; Title: Re: Get Checkbox value from EditForm modal dialog in Basic CRUD application Post by: andyj on May 26, 2014, 08:33:11 AM Thanks very much.
That has certainly resolved the issue. I still don't understand why the update() function didn't work though... It ought to? |