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 by  Ankit Singh
 1026  View(s)
Ratings:
Rate this:
call single click event and change value of dropdown list according to clicked button usin jquery
  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: How to call single click event on click multiple button and select value in dropdown according to click button using JQuery

    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>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!