My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to change values on input change and get fix output value to particular input value?

Prashant Tiwari's photo
Prashant Tiwari
·Mar 16, 2020

I want to bind bus number(1-40) with their particular RTO number (like BR0215,BRDF45 and so on..)

The RTO number of particular bus should be display in text box beside the bus number input field, when i enter any bus number(1-50).

I have tried the following codes, but this is so long method because buses are 40 and also it is based on drop-down concept. Please help me to find its solution because i don't want drop-down list. I want input values of buses.

var bus = {'1':['CG154' ], '2':['CG025' ], '3':['CG108' ]};
        $('#busdown').on('change', function(){
            var buslist = bus[$(this).val()];
            console.log(buslist);
            var output = '';
            $(buslist).each(function(k, v){
                output += '<option value="'+v+'">'+v+'</option>';
            });
            $('#RTONo').html(output);
        });

<!-- language: lang-html -->

    <select id="busdown">
        <option value="1">25</option>
        <option value="2">26</option>
        <option value="3">24</option>

    </select>
    <select id="RTONo"></select>