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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disabling multiple form fields, but keeping 1 radio button active?

Status
Not open for further replies.

WestSide2003

Technical User
Jan 22, 2003
42
0
0
US
Hi,

I have 1 form with 6 form elements on it. 2 radio buttons, 4 text boxes

I want to disable all but one of the elements. Basically there are two radio buttons and 4 text boxes.

If the first radio button is selected, then all the other fields should be disabled.

If the user chooses the 2nd radio button, all the fields should be enabled. the 4 fields should only be allowed to be enabled if the user chose the 2nd radio button.

How can I do this?

The tables have ID tags. Right now I am using:

PageChoices.disabled=true;

where PageChoices is the ID of the table where the 4 text boxes exist. This does work, except I can still enter data into the text boxes, they are greyed out, but still allow input.

Any idea why?

-WS
 

>> If the first radio button is selected, then all the other fields should be disabled.

If you disable all the other fields, then how will the user ever manage to click the second radio button? Are you sure this is really what you want to do?

Dan
 
and why disable the <td> when u can disable the field???

Known is handfull, Unknown is worldfull
 
Hi,

Yes, your right Dan....

all fields are disabled except BOTH radio buttons, that was my bad. The two radio buttons are not disabled.

Its the 4 form fields that are disabled/greyed out.

There is no <td> being disabled. I have an html table with and ID attached to it.

So when the page loads this code is ran: PageChoices.disabled=true;

However, I can still enter text in the text boxes even though the fields are disabled. I am trying to get the greyed out look, and prevent any text input in the 4 form fields unless the 2nd radio button is chosen..

Hope that helps clarify...

-WS
 
you could just name everything in the form with an id of say, 1 or hideme or whatever... then

function hidestuff(idname)
{
var stuffData = document.getElementsById(idname);
for(var i = 0; i < stuffData.length; i++) {stuffData.style.visiblity = 'none';}
}

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top