Thursday, 20 July 2017

Get Price in Textbox on Value change in Dropdown using HTML, Jquery and Javascript:-

Link Jquery file in your project:-


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript" src="jquery-1.10.2.js"></script>

    <script>
        $(document).ready(function () {

            $("#ddl_cat").change(function () {
                debugger;  
                var a = document.getElementById("ddl_cat").value;
                if (a == "Burger")
                {
                    document.getElementById("txt_price").value = '200';
                }
                else if (a == "Cold Drink") {
                    document.getElementById("txt_price").value = '100';
                }


            });


        });
    </script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        category:
   <select id="ddl_cat">
       <option>---select---</option>
       <option>Burger</option>
       <option>Cold Drink</option>
   </select>

        <br />
       Price:
        <input type="text" id="txt_price" />
    </div>
    </form>
</body>
</html>

No comments:

Post a Comment

Insert, Delete, Update Using Entity Framework and LINQ in ASP.NET 1> Create Database First 2> Create Table 3> Add ADO...