dimanche 2 août 2015

Convert JSON response to Checkboxes

I am working on project which get response from my service as JSON string. Which is array of JSONObjects like:

 [{
        "ID": 1,
        "Role": "1 - This is ROLE."
        "child" [
            {
                "ID": 10,
                "Role": "1 - This is ROLE."
            },
            {
                "ID": 11,
                "Role": "1 - This is second ROLE."
            }   
        ]
    },
    {
        ... so on
    }
 ]

I need help to generate parent and child checkboxes fieldsets of above JSON string using jQuery or Javascript. Idea is; by clicking parent checkbox all child checkboxs will checked automatically. Else only child checkbox!

Here is JSFiddle, just check the result windows only which is desired! http://ift.tt/1OXNLfB

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire