JSFiddle - React, Tailwind, and code Playground

by StealingMana

HTML

<FORM NAME="myform" ACTION="" METHOD="GET">
    <input type="button" name="accessories" value="Accessories" onClick="runList(this.form,0)"/>
    <input type="button" name="weapons" value="Weapons" onClick="runList(this.form,1)"/>
    <select id="mylist"/>
</form>

JavaScript

var accessoryData = ["value1", "value2" ];
var weaponData = ["valueA", "valueB" ];

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

function dataType(test) {
    if (test == 0) {
        dataType = accessoryData;
    } else if (test == 1) {
        dataType = weaponData;
    }
}