954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Enable and disable controls in .aspx page using javascript?

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

BalagurunathanS
Light Poster
26 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

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" />
        
        
        <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" />
        
        
        <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>
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You