lundi 26 février 2018

Validate dynamic checkbox

I have two tables in the database, Table A and Table B. User fill up Form A that will insert new record in Table A. In Form B, the records in Table A are called as checkbox. From this form, the data will be inserted into Table B. The following code are in Form B. The data captured in this code will be inserted into a column (let say column name is menu_check), resulting something like "value1,value2,value3" (depending on how many checkbox the user check)

<input type="checkbox" name="chckmenu" id="chckmenu" value="#qMenu.menu_id#"   />#qMenu.menu_name_eng#

After Form B is complete, user will be directed to a page where shows the list of all records in Table B. From this table, user can edit any records. Something like a simple listing where the user can view, update or delete any records. In the edit page, how to call out the value of menu_check, and see if any checkbox are checked or not based on the column.

For example; If value in menu_check is 'value1,value2,value3', only the first, second and third checkbox are checked. If value in menu_check is 'value1,value3', only first and third checkbox are checked.




Aucun commentaire:

Enregistrer un commentaire