I have the following select
:
<select name="idservico[]" id="idservico">
<option data-valor="25,00" value="1">opção 1</option>
<option data-valor="20,00" value="1">opção 2</option>
</select>
I have the following input
:
<input type="text" name="valor" id="valor"/>
I have the following script
:
<script>
jQuery(document).ready(function () {
jQuery('#idservico').change(function() {
jQuery('#valor').val((jQuery(this).find(':selected').data('valor')));
});
});
</script>
So let's go, when I select a service it sends the value of the service to input
, but I need it when I select another service - because my select
is multiple - it would have to add the value of the first one selected with the second.
Can anyone help me? You can even select and send the value to input
, but add nothing so far. Thankful.