Check on selectfield and input field Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Check on selectfield and input field without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m trying to do the following:

I have 1 select field and 1 input field. When these are filled out the sum of both has to be written to the span .result. (Immediately! So not off focus from input field etc.)

I tried to use:


and so on…

It only works on either input or selectfield but not on both at the same time.

To make this situation a bit more clear I added a fiddle


Use input and select events.

$('input, select').on('input select', function() {
  1. input event will be fired when the value of the input is changed either by manually entering the value or by copy-paste.
  2. select event will be fired on <select> when an <option> is selected.

Updated Fiddle

$('input, select').on('input select', function() {
    prijs_field = $('.prijs_field').val();
    btw_field = $('.btw_field').val();
    $('.result').html(prijs_field * btw_field);
<script src=""></script>
<input type="text" class="prijs_field">
<select class="btw_field">
    <option value="21">21%</option>
    <option value="6">6%</option>
    <option value="0">0%</option>
<span>the result is: </span><span class="result"></span>
We are here to answer your question about Check on selectfield and input field - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji