/    Sign up×
Community /Pin to ProfileBookmark

Basic level question

Hello guys,

I’m new to js, and I don understand this piece of script:

[CODE]
imgs : {
‘ore1’ : {name : __(‘description here’), css : {‘font-weight’ : ‘bold’}},
‘ore2’ : {name : __(description here), css : {‘font-weight’ : ‘bold’}},
‘ore3’ : {name : __(description here), css : {‘font-weight’ : ‘bold’}},
}[/CODE]

I’d like to know how can I add more items to the list.

In fact, I was googling for info about this tipe of construction, but I did find nothing.

Thanks in advance,

Sergio

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KuriyamaJul 31.2009 — I don't think that script will run correctly in the first place. you need to drop the trailing comma.

Try to do it like, and check out JavaScript Arrays, and JSON

[CODE]
imgs : {
'ore1' : {name : __('description here'), css : {'font-weight' : 'bold'}},
'ore2' : {name : __(description here), css : {'font-weight' : 'bold'}},
'ore3' : {name : __(description here), css : {'font-weight' : 'bold'}},
[COLOR="Red"]'addedvale' : {name: "descriptiong here", css:{'font-weight': 'bold', 'color': 'red'}}[/COLOR]
}
[/CODE]
Copy linkTweet thisAlerts:
@sergioxauthorJul 31.2009 — Thanks [B]Kuriyama[/B], and excuse me:

I did paste only a piece of the list, and I forgot to delete the coma. The script works, but I'd like to add items to the [I]imgs[/I] list.

Could you tell me what kind of construction is that?

It's a kind of array?

Cheers, and thankz again.

Sergio
Copy linkTweet thisAlerts:
@sergioxauthorJul 31.2009 — I mean, I'd like to use a for loop in order to add more items.
Copy linkTweet thisAlerts:
@sergioxauthorJul 31.2009 — I did try this, but is not working:

[CODE]for(i=1;i<=20;i++){
buttons.push(" {'separator'+i+ : {},} ,");
}[/CODE]
Copy linkTweet thisAlerts:
@KuriyamaJul 31.2009 — I did try this, but is not working:

[CODE]for(i=1;i<=20;i++){
buttons.push(" {'separator'+i+ : {},} ,");
}[/CODE]
[/QUOTE]


www.json.org

Take a look at that website and this will make a lot more sense to you.
Copy linkTweet thisAlerts:
@sergioxauthorJul 31.2009 — Thanks again Kuriyama. I'll review the site.
×

Success!

Help @sergiox spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...