Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 18th, 2006, 12:58 PM
Friend of Wrox
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default Enabling and Disabling form elements

I'm developing a website that has a large input form.
What I want to do is disable a few form input elements that
only become enabled when a user has selected another form

As a tester, I've been playing around with some test code
I've written - but my theory doesnt work as when the code
was tested in IE - I get a javascript error saying element not an
object or null.

Could anyone advise me where I'm going wrong with the following simply

<head><title>Test Doc</title>

<script language="javascript">

function formdis(){






<form id="form1" method="post" action="#">

<input type="text" id="box1" size="25" />

<input type="text" id="box2" size="25" onclick="formdis()" />

<input type="text" id="box3" name="box3" size="25" disabled="disabled" value="extra choice" />


Old February 18th, 2006, 01:29 PM
Friend of Wrox
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919

Hi Socoolbrewster!!

either use
<form id="form1" method="post" action="#" name="form1" >
use (1) document.forms[0].box3.disabled=false;

    or (2) document.form1.box3.disabled=false;

<form id="form1" method="post" action="#">
 use (1) document.forms[0].box3.disabled=false;

Hope this will help you

Cheers :)

Old February 18th, 2006, 05:22 PM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Either name your form and elements using the name attribute or, if you want to access by id then use:
document.getElementById("box3").disabled = false;
to enable. You will need to name the elements if you wish to read the form data when it's submitted.


Joe (Microsoft MVP - XML)
Old February 21st, 2006, 05:48 AM
Authorized User
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

Is it possible to show a controls enabled/disabled state using javascript?


if radiobuttonlist web control set enabled = false , in javascript
cannot enable it.
because radiobuttonlist generate some span tag , i cannot catch it compete.
Have some javascript code suit, to wraper web control property and method.


Old February 21st, 2006, 04:45 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post

jitendersingal can you provide some more detail on your requirements ?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling form elements on click of checkbox Shuchik Classic ASP Basics 2 September 12th, 2007 02:53 AM
Enabling/Disabling Form Controls lbyii Javascript 6 October 13th, 2006 07:36 AM
Enabling and disabling Required field Validators mrufus General .NET 0 June 27th, 2006 03:44 AM
Disabling/enabling the textbox of EditCommandColu ninel ASP.NET 1.0 and 1.1 Professional 1 February 20th, 2006 04:39 PM
MS-Outlook, enabling/disabling rules shamigc VBScript 0 August 4th, 2004 08:57 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.