Answer the question
In order to leave comments, you need to log in
How to pass an array to js?
Hello.
It is necessary to pass an array to JS
An array comes from the controller (collection). i get all id
there js script
$top_menu->pluck('id')
// 1 часть меню
but_g_menu. onclick = function() {
if(id_g_menu. style . display == "none") {
id_g_menu.style . display= "";
}
else { id_g_menu.style . display = "none"; }
}
// 2 часть меню
var id_menu = new Array('1111','2222','3333');
startList = function allclose() {
for (i=0; i < id_menu.length; i++){
document.getElementById(id_menu[i]).style.display = "none";
}
}
function openMenu(id){
for (i=0; i < id_menu.length; i++){
if (id != id_menu[i]){
document.getElementById(id_menu[i]).style.display = "none";
}
}
if (document.getElementById(id).style.display == "block"){
document.getElementById(id).style.display = "none";
}else{
document.getElementById(id).style.display = "block";
}
}
window.onload=startList;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question