This is what I have but I don't know how to get it to a variable in JS
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<button onclick="myFunction()">set</button>
<script>
function myFunction() {
var x = document.title;
}
</script>
In this code you are storing current title in var x. you need to write like this:
document.title="Some Text or variable";
if you need to set value of dropdown item as title then to give id to select tag then var newtitle = document.getElementById("id_of_selectTag").value; document.title=newtitle;