0

Want to create a JavaScript array, after click event.
This is my function:

$(function() {

     $('#tree,#tree-combined').on('acitree', function(event, api, item, eventName, options) {
         if (api.isItem(item)) {
             var itemSelect= [];
             itemSelect.push(api.getId(item));
             var itemEvent= eventName;
             if (event) {
                 if (itemEvent=="checked") {
                     var a = api.getId(item);
                     eval('var arrayTmp = ' + a); 
                     document.getElementById("Name").value = arrayTmp;
                 }
             }
         } else {
             var itemEvent1= eventName;
         }
     });
});

And I want to use this array as hidden input field

<input type="hidden" id="Name[]" name="Name[]" />
3
  • Create a fiddle and please mention the problems which you are facing. Commented Aug 14, 2015 at 5:23
  • 2
    user json stringify and then add it into hidden field Commented Aug 14, 2015 at 5:52
  • Please give me an example related to my proble that how would i use json stringyfy. Thanks Commented Aug 17, 2015 at 9:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.