i have a javascript code below.

bgCustom = { 'items':[], 'items_num':3, 'element':'#bg_custom_thumbs', 'next': '#bg_custom_next_thumb', 'prev': '#bg_custom_prev_thumb', 'width':165 };
//populate array
bgCustom.items = [["images/backgrounds/bear-ears_thumb.jpg", "bear-ears.jpg", "Bear-Hair"], ["images/backgrounds/blue-swirls_thumb.jpg", "blue-swirls.jpg", "WaterSmoke"]];

ho do i create bgCustom.items array dynamic. means i want a array list

[['val1_1','val1_2','val1_3'],['val2_1','val2_2','val2_3']]

Can any body help me.

share|improve this question

53% accept rate
What do you mean by 'dynamic'? – mamoo Aug 4 '11 at 13:52
how do i creat this type of array [['val1_1','val1_2','val1_3'],['val2_1','val2_2','val2_3']] – Pathik Gandhi Aug 4 '11 at 13:53
1  
I don't see what the problem is, everything you've done should work. – Richard Dalton Aug 4 '11 at 13:53
yes but right now bgCustom.items is static values i want dynamic values – Pathik Gandhi Aug 4 '11 at 13:54
Still not clear what you mean by saying static or dynamic. In that array you can push values, remove values, change values... so what exactly are you trying to achieve? – mamoo Aug 4 '11 at 13:57
show 1 more comment
feedback

2 Answers

up vote 0 down vote accepted
bgCustom = { 'items':[], 'items_num':3, 'element':'#bg_custom_thumbs', 'next': '#bg_custom_next_thumb', 'prev': '#bg_custom_prev_thumb', 'width':165 };

function PushToItems(a,b,c) {
    var ar = [a,b,c];
    bgCustom.items.push(ar);
}

PushToItems("images/backgrounds/bear-ears_thumb.jpg", "bear-ears.jpg", "Bear-Hair");

That should work for making it a little more dynamic.

share|improve this answer
Thnanks it working – Pathik Gandhi Aug 5 '11 at 4:59
You're welcome. :) Glad to help. – Joseph Marikle Aug 5 '11 at 12:57
feedback

You can add arrays to the end of the array:

bgCustomer.items.push(['val1_1','val1_2','val1_3']);
bgCustomer.items.push(['val2_1','val2_2','val2_3']);

You can also assign arrays at specific indexes. The array will automatically expand if you use an index outside the current size:

bgCustomer.items[0] = ['val1_1','val1_2','val1_3'];
bgCustomer.items[1] = ['val2_1','val2_2','val2_3'];
share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.