Hi all..

I am having controls such as dropdown,button,textbox in my aspx page .I need to enable and disable them using javascript..I am beginner in Javascript...Some one help with code in javascript as early as possible...

Thanks & regards,

Balaguru

See this sample snippet:

<html>
<head>
</head>
<body>
    <form name="frm">
        <input type="text" name="txt" value="Hello" />
        <input type="button" onclick="this.form.txt.readOnly = true;" value="Disable text field" /> 
        <input type="button" onclick="this.form.txt.readOnly = false;" value="Enable text field" />
        <br /><br />
        
        <input type="button" value="My Button" name="btn" /> 
        <input type="button" onclick="this.form.btn.disabled = true;" value="Disable button" /> 
        <input type="button" onclick="this.form.btn.disabled = false;" value="Enable button" />
        <br /><br />
        
        <select name="mySelect">
            <option value="india">India</option>
            <option value="america">America</option>
        </select>
        <input type="button" onclick="this.form.mySelect.disabled = true;" value="Disable drop down" /> 
        <input type="button" onclick="this.form.mySelect.disabled = false;" value="Enable drop down" />
    </form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.