如何将多个JS函数调用的结果分配给PHP数组?

时间:2015-11-14 20:13:19

标签: javascript php arrays

1.我有JS函数创建HTML数组 2.此函数被多次调用,因此也会创建多个数组 3.如何将所有创建的HTML数组分配为新PHP数组的键?

var nextId = 0;

function addLanguage() {

nextId++;

var inputDiv = document.createElement("div");

inputDiv.setAttribute("id","num" + nextId);

inputDiv.innerHTML = 
    "<input type='text' name='langs[]'/>"
    +
    "<select name='langs[]'>\n\
        <option value='comprehension'>-comprehension-</option>\n\
        <option value='beginner'>beginner</option>\n\
        <option value='intermediate'>intermediate</option>\n\
        <option value='advanced'>advanced</option>\n\
    </select>"
    +
    "<select name='langs[]'>\n\
        <option value='reading'>-reading-</option>\n\
        <option value='beginner'>beginner</option>\n\
        <option value='intermediate'>intermediate</option>\n\
        <option value='advanced'>advanced</option>\n\
    </select>"
    +
    "<select name='langs[]'>\n\
        <option value='writing'>-writing-</option>\n\
        <option value='beginner'>beginner</option>\n\
        <option value='intermediate'>intermediate</option>\n\
        <option value='advanced'>advanced</option>\n\
    </select><br>"
    +
    "<input type='button' value='Remove Language' onclick='removeLanguage(\"num" + nextId + "\")'>"
    +
    "<button type='button' value='press' onclick='addLanguage()'>Add Language</button>"
    ;

        document.getElementById('langs').appendChild(inputDiv);

}

因此多次调用addLanguage()并创建多个langs []数组。如何将这些数组作为另一个数组的键分配?

0 个答案:

没有答案