Setting a textfield based on Dynamically populated drop-down

There is a post about the above mentioned problem (created in 2011).
It’s almost perfectly working I just have one question.

I fill my text field with a selected value from a dropdown field. Unfortunately it only works
if I change the selection in dropdown menu. Is there a possibility that my text field gets the entry in the dropdown menu without I have to change the the selection?

Here is my code:

...
 <select class="form-control" id="auswahl"                                                                                                  name="lehrgang" onchange="auswahl()">

                                           
<script type="text/javascript">
var form = document.getElementById('test'),
auswahl = form.elements.auswahl;

auswahl.onchange = function () {
var form = this.form,
auswahl = this,
feld = form.elements.feld;
feld.value = auswahl.options[auswahl.selectedIndex].text;
};
 </script>

Maybe the problem is the “onchange” because that’s what I exactly not like. It should get the value immediately not only on change…
I tried it with onfocus but that’s neither the effect I am looking for

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.