1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
function addBrand(id)
{
var li_brand = document.createElement('li');
var input_title_brand = document.createElement('input');
var input_requete_brand = document.createElement('input');
input_title_brand.setAttribute("name","level2_titles["+id+"][]");
input_title_brand.setAttribute("class","inputText");
input_title_brand.setAttribute("value","Brand name");
input_requete_brand.setAttribute("name","level2_requetes["+id+"][]");
input_requete_brand.setAttribute("class","inputText");
input_requete_brand.setAttribute("value","Brand requete");
li_brand.appendChild(input_title_brand);
li_brand.appendChild(input_requete_brand);
alert(document.getElementById("brand_list_"+id));
document.getElementById("brand_list_"+id).appendChild(li_brand);
}
function addCategory()
{
var li_category = document.createElement('li');
li_category.setAttribute("class","category_li");
var input_title_category = document.createElement('input');
input_title_category.setAttribute("name","level1_titles[]");
input_title_category.setAttribute("class","inputText");
input_title_category.setAttribute("onChange","save()");
input_title_category.setAttribute("value","Category name");
var input_requete_category = document.createElement('input');
input_requete_category.setAttribute("class","inputText");
input_requete_category.setAttribute("name","level1_requetes[]");
input_requete_category.setAttribute("onChange","save()");
input_requete_category.setAttribute("value","Category requete");
var aDelete = document.createElement('a');
aDelete.setAttribute("href","#");
aDelete.setAttribute("onClick","deleteCategory(this.parentNode)");
aDelete.appendChild(document.createTextNode("delete"));
li_category.appendChild(input_title_category);
li_category.appendChild(input_requete_category);
li_category.appendChild(aDelete);
var ul_brand = document.createElement('ul');
var li_brand = document.createElement('li');
var input_title_brand = document.createElement('input');
var input_requete_brand = document.createElement('input');
var id = document.getElementsByName('level1_titles[]').length;
input_title_brand.setAttribute("name","level2_titles["+id+"][]");
input_title_brand.setAttribute("class","inputText");
input_title_brand.setAttribute("value","Brand name");
input_requete_brand.setAttribute("name","level2_requetes["+id+"][]");
input_requete_brand.setAttribute("class","inputText");
input_requete_brand.setAttribute("value","Brand requete");
var aAddBrand = document.createElement('a');
aAddBrand.setAttribute("href","#");
aAddBrand.setAttribute("onClick","addBrand("+id+")");
aAddBrand.appendChild(document.createTextNode("add Brand"));
li_brand.appendChild(input_title_brand);
li_brand.appendChild(input_requete_brand);
ul_brand.appendChild(li_brand);
li_category.appendChild(ul_brand);
li_category.appendChild(aAddBrand)
document.getElementById('category_list').appendChild(li_category);
save();
} |
Partager