I am wondering how to write a price in a div when a user selects an option in a dropdown menu.
Asked
Active
Viewed 29 times
1 Answers
1
The information you provided was a little vague. However, based off of what you provided, I believe this is what you're attempting to accomplish.
<select id="myDropdown">
<option id="opt1">Option 1</option>
<option id="opt2">Option 2</option>
<option id="opt3">Option 3</option>
<option id="opt4">Option 4</option>
<option id="opt5">Option 5</option>
</select>
<div id="result"></div>
If you have HTML like the above some where in your page, you can add some jQuery to the bottom of your page that should update your div accordingly.
<script type="text/javascript">
$(document).ready(function() {
$('#myDropdown').change(function() {
$('#result').html('<span class="money">$123.45</span>');
});
});
</script>

Cliff Gunn
- 458
- 2
- 7
-
$('#result').html( $('#myDropdown').val() ); see https://stackoverflow.com/questions/11179406/jquery-get-value-of-select-onchange – John Griffiths Oct 29 '19 at 20:09
-
@JohnGriffiths great link. That thread is far better than the example I provided here. – Cliff Gunn Oct 29 '19 at 21:14