The definition of the array in PHP is simple, but in JS if the character for the next RCAs error, so the combination of objects to engage in
var top_ = {
' index ': ' Home ',
' user ': ' Users ',
' tree ': ' Module Trees '
};
var all_list = [
{
"index": [
{' name ': ' website column management ', ' url ': ' 1.html '},
{' name ': ' website column Management 2 ', ' url ': ' 2.html ' }
]
},
{
"user": [
{' name ': ' admin ', ' url ': ' user.html '},
{' name ': ' user added ', ' url ': ' Add.html '}
]
},
{
"tree": [
{' Name ': ' Module Trees management ', ' url ': ' manager.html '},
{' name ': ' Module tree add ', ' url ': ' add_new.html '},
{' name ': ' Module tree Tim 333 Plus ', ' url ': ' add_ne33w.html '}
]
}
;
The above defines a module tree array ....
It's also very good to take out the data.
The left menu
function Return_left_menu_by_index (index) {
var Left_ = '
is obtained according to the subscript at the top. for (var i in all_list) {
for (Var j in All_list[i]) {
if (j = = index) {
//default menu displayed
//console.dir (all_list[i) [j]);
For (var k in All_list[i][index]) {
//console.dir (k);
var New_onclick = ' Onclick=change_right_url (' +all_list[i][index][k].url+ ') ';
left_+= ' <div style= ' width:120px; Height:30px;line-height:30px;border:solid 1px; Margin:3px;padding:2px;cursor:pointer "' +new_onclick+ ' > ' +all_list[i][index][k].name+ ' </div> '
}
}
}
}
return left_;
}
The above JS definition object Array (combined) multidimensional array method is small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.