Tuesday, July 9, 2019

Change event in JavaScript

Onchange event will be fired when control value has been changed.
Code Sample:

<html>
<head>
    <title>Onchange event example in JavaScript</title>
    <script language="Javascript">

        function selctcntry(evt, t) {
            if (t.selectedIndex > 0)
                document.getElementById("Text1").value = t.value;
            else
                document.getElementById("Text1").value = "";
        }

    </script>
</head>
<body>
    <table align="center">
        <tr>
            <td>
                <input type="text" id="Text1" />
            </td>
        </tr>
        <tr>
            <td>
                Select the country name from the dropdown
            </td>
        </tr>
        <tr>
            <td>
                <select onchange="selctcntry(event,this);">
                    <option value="India">Select</option>
                    <option value="India">India</option>
                    <option value="USA">USA</option>
                    <option value="China">China</option>
                    <option value="Japan">Japan</option>
                    <option value="Canada">Canada</option>
                </select>
            </td>
        </tr>
    </table>
</body>
</html>

No comments:

Post a Comment

Lab 09: Publish and subscribe to Event Grid events

  Microsoft Azure user interface Given the dynamic nature of Microsoft cloud tools, you might experience Azure UI changes that occur after t...