How to populate a form list with buttons using javascript

Posted by StealingMana on Game Development See other posts from Game Development or by StealingMana
Published on 2012-06-12T20:37:45Z Indexed on 2012/06/12 22:49 UTC
Read the original article Hit count: 192

Filed under:

I made a script that, when you press one button(accessories) the selection(mylist) populates with one array(accessoryData), and when you hit the other button(weapons) the other array(weaponData) populates the selection. However, in the current state of the code the second button press is not re-populating the selection. What is wrong here?

Also if there is a more efficient way to do this, that might be helpful.

Full code

function runList(form, test) {
    var html = "";
    var x;
    dataType(test);
    while (x < dataType.length) {
        html += "<option>" + dataType[x];
        x++;
    }
    document.getElementById("mylist").innerHTML = html;
}

© Game Development or respective owner

Related posts about JavaScript