0

When clicking a div I need to store a few data into a hidden input field the data will take the form like this

term_name:has_children:parent_id|

As more divs are clicked their will be more data

postA:1:275|postB:0:375

etc, how do i split this into an array for processing? With php i would simply do

explode ('|','string');

I would need to do this twice here once with '|' and then again with ':'

I hope my question is clear. Please let me know if it is not Thank You in Advance

Digamber
  • 448
  • 6
  • 14
  • `var newArray = string.split("|");` and you repeat that split in each "newArray" element. If you're using jquery you may also either use .each or .map for such a thing. What do you need to do after splitting? – briosheje Mar 12 '15 at 08:32
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split – Barmar Mar 12 '15 at 08:32
  • I need to process it in a way that 1) I have to check every for every div in the current document depending on term_name. 2) then check if term name has_children 3) is term_name has_children then take the parentID and find corresponding children through an Ajax call then find the Children in current document and add a few classes to those children I was hoping to do something like break it into arrays and sub-arrays however i'm not that good in javascript. if you have a suggestion i'm open to ideas – Digamber Mar 12 '15 at 09:13

0 Answers0