Home > DeveloperSection > Forums > How to call single click event on click multiple button and select value in dropdown according to click button using JQuery
Ankit Singh

Total Post:341

Points:2389
Posted on    September-29-2014 7:54 AM

 JQuery JavaScript  JQuery 
Ratings:


 1 Reply(s)
 782  View(s)
Rate this:
call single click event and change value of dropdown list according to clicked button usin jquery


Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    September-29-2014 8:14 AM

Hi ankit i'm try to solve your problem

here is my html code

<div class="container">
    <div class="row">
        <br /><br />
        <div class="col-md-1">
            <input type="button" value="Allahabad" class="selectcity btn btn-info" id="0"/>
        </div>
        <div class="col-md-1">
            <input type="button" value="Lucknow" class="selectcity btn btn-info" id="1"/>
        </div>
        <div class="col-md-1">
            <input type="button" value="Kanpur" class="selectcity btn btn-info" id="2"/>
        </div>
        <div class="col-md-1">
            <input type="button" value="Delhi" class="selectcity btn btn-info" id="3"/>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4" ><br /><br />
            <select id="ddl-jobcategory" style="width:100%;height:35px;">
                <option>Allahabad</option>
                <option>Lucknow</option>
                <option>Kanpur</option>
                <option>Delhi</option>
            </select>
        </div>
    </div>
</div>

and here is my jquery code

<script>
    $(document).ready(function () {
        $('.selectcity').click(function () {
            var index = $(this).attr("id");
            $('#ddl-jobcategory').prop("selectedIndex", index);
        });
    });
</script>

Don't want to miss updates? Please click the below button!

Follow MindStick