Home>

Defining an array in php is simple,However, in js, if the character is used as a subscript, an error will occur.So combining objects to do

var top_={
"index":"Home","user":"User","tree":"Module Tree"
};
var all_list=[
{
"index":[
{"name":"Site section management", "url":"1.html"},{"name":"Site section management 2", "url":"2.html"}
]
},{
"user":[
{"name":"User management", "url":"user.html"},{"name":"User add", "url":"add.html"}
]
},{
"tree":[
{"name":"Module tree management", "url":"manager.html"},{"name":"Module tree addition", "url":"add_new.html"},{"name":"Module tree 333 plus", "url":"add_ne33w.html"}
]
}
];

An array of module trees is defined above. . . .

In addition, it is also very good when taking out the data.

//Get the left menu according to the subscript at the top
function return_left_menu_by_index (index) {
var left_="";
for (var i in all_list) {
for (var j in all_list [i]) {
if (j == index) {
//Menu displayed by default
//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" + new_onclick + ">" + all_list [i] [index] [k] .name + "</div>";
}
}
}
}
return left_;
}
  • Previous Python batch production method of radar chart
  • Next The main character and related elements of the Android combat aircraft game (3)