function populateselection(input) { for (i=0;i < input.options.length; i++) { input.options[i].selected ? chosenoption=input.options[i].value : donothing=donothing } window.status=chosenoption } <form name="selectinterface"> <select name="refererselect" onchange="populateselection(selectinterface.refererselect)"> <option name="topreferer" value="nothing">view stats per referer</option> {% for referer in refererlist %} <option name="{{ referer }}" value="{{ referer }}">{{ referer }}</option> {% endfor %} </select> </form>