var counter = 1;

function addNewInput(element) {
    if (element == document.getElementById("inputs").lastElementChild) {
        var newinput = document.createElement('input');
        counter += 1;
        newinput.setAttribute("type", "text");
        newinput.setAttribute("onFocus", "addNewInput(this);");
        newinput.setAttribute("placeholder", "Enter poll option...");
        newinput.setAttribute("name", "q" + counter);
        document.getElementById("inputs").appendChild(newinput);
    }
}
