input type hidden value and get value in ID
jQuery(function($) { //var selectedValues = val(subject;?>).split(','); var selectedsub = $("#subjectval").val().split(','); var selectedrelevant_law = $("#relevant_lawval").val().split(','); var selectedsectionval = $("#relevant_sectionval").val().split(','); var selectedcourtval = $("#courtval").val().split(','); var selectedjudgeval = $("#judgeval").val().split(','); var selectedadvocateval = $("#advocateval").val().split(','); $("#subject").select2().select2('val',selectedsub); $("#relevant_law").select2().select2('val',selectedrelevant_law); $("#relevant_section").select2().select2('val',selectedsectionval); $("#court").select2().select2('val',selectedcourtval); $("#judge").select2().select2('val',selectedjudgeval); $("#advocate").select2().select2('val',selectedadvocateval); });