You have alert()
in wrong place
<select name="select1" onchange="updatevariable(this.value)">
<option value="2" >2</option>
<option value="15" >15</option>
</select>
<script type="text/javascript">
var value = "test";
function updatevariable(data) {
value = data;
alert(value);
}
</script>
In your code it is loaded right after the script is loaded,
you have to modify it to be called right after change
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…