Get the value of select tag and copy it to another input tag

I have a form with select tag in it named “cost”. I would like to write a function updateText() that would do the following

  1. get the value of selected option withing that select tag
  2. do some math with like add some other number
  3. copy the result od 2. into input tag named “sum”
 <script type="text/javascript">
function updateText() {
}
</script>

<select name="cost" id="cost" onchange="updateText()">
<option>100</option>
<option>200</option>
<option>300</option>
</select>   
<input type="text" name="sum" id="sum" />

Please help me with some tips about what to write in updateText().

Thanks in advance.


<script type="text/javascript">
function updateText(n) {
	var sel= document.getElementById('cost');
	var inputSum= document.getElementById('sum');
	var selValue = sel.options[sel.selectedIndex].value;
	inputSum.value= +selValue + n;
}
</script>
<select name="cost" id="cost" onchange="updateText(3)">
<option>100</option>
<option>200</option>
<option>300</option>
</select>
<input type="text" name="sum" id="sum" />

Bye.