If you are using jquery just select
$('select.foo option:selected').val();
UPDATE (I forgot to include the population <input>)
First, inlcude jquery in your html file.
In <header>you turn it on:
<header>
<script type="text/javascript" src="YOUR_PATH_TO_LIBRARY/jquery-1.7.1-min.js"></script>
</header>
Then
<input type="text" name="txtprice" id="txtprice" onClick="javascript:$('select.foo option:selected').val();">