I have an HTML like this:
<div class="pgggo-list-taxon">
<li>
<label>
<input type="checkbox" name="pgggo-category-sep-56[]">
<div class="icon-box">
<div name="development">Development</div>
</div>
</label>
</li>
<li>
<label>
<input type="checkbox" name="pgggo-category-sep-14[]">
<div class="icon-box">
<div name="food">Food</div>
</div>
</label>
</li>
<li>
<label>
<input type="checkbox" name="pgggo-category-sep-8[]">
<div class="icon-box">
<div name="medical">Medical</div>
</div>
</label>
</li>
<li>
<label>
<input type="checkbox" name="pgggo-category-sep-1[]">
<div class="icon-box">
<div name="uncategorized">Uncategorized</div>
</div>
</label>
</li>
<li>
<label>
<input type="checkbox" name="pgggo-category-sep-2[]">
<div class="icon-box">
<div name="wordpress">WordPress</div>
</div>
</label>
</li>
</div>
Each checkbox has unique name = pgggo-category-sep-56, pgggo-category-sep-14. As multiple items are clicked the ids are added to the id field of below array.
I am trying to have a method which gives me an array as output:
$output = array(
array(
'taxonomy'=> 'category', // pgggo-category-sep-56 --category word is pulled from here
'id'=> array(56,14), // ids are pulled pgggo-category-sep-56 number at the end
)
array(
'taxonomy'=> 'home', // pgggo-home-sep-56 --homeword is pulled from here
'id'=> array(56,14), // ids are pulled pgggo-category-sep-56 number at the end
)
);
I tried this:
$('.pgggo-container-ajax-sorting').on('click', '.pgggo-list-taxon input', function(event) {
var outputPgggo = $(this).attr('name');
}
But this only pulls the string. Is there any way to get this done?
categoryand in the second onehome?homebecomes the id of it 's array