Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling Form Fields

Status
Not open for further replies.

tyrant1969

Programmer
Dec 13, 2004
68
US
I have a form that has a variety of fields and input options. I am attempting to disable certain checkboxes when an option is chosen from the drop down menu.

The core of the problem is that if the checkbox is initially formatted like this:
Code:
<input type="checkbox" name="existing" value="existing1" id="ex1">

Such that it is an enabled field from the get-go, the javascript command of:

Code:
opener.document.getElementById('ex1').disabled = true;

Does not work!

But if I turn around, setup that exact same checkbox like this so that it is disabled:

Code:
<input [b]disabled[/b] type="checkbox" name="existing" value="existing1" id="ex1">

Then enable it first thing and later on disable it using javascript after the appropriate selection has been made, then all works just fine.

Why won't the box disable simply using the .disabled=true option?

Any suggestions welcomed!
 
Nevermind...it is definitely one of those days where I should drink coffee before posting code questions!

The code I cut-n-pasted was from my test server and it was coded correctly, but the code that I was actually attempting to run was from my live server. Where the javascript was attempting to access an id that existed, but wasn't an input field. So no errors were thrown back, but disabling a div really doesn't do one heck of a lot of good.

Sorry for wasting you time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top