# Javascript: Enabling/Disabling Fields Based on Radio Selection



## diggingforgold (Oct 6, 2001)

Ok, here's the scenario. I have 3 radio buttons. When a particular radio button is selected, only that field directly beneath that radio button should be enabled- otherwise, it should be disabled.

Radio 1 = No fields
Radio 2 = Drop menu
Radio 3 = Text field

Hopefully you can tell what I'm trying to do with my really n00bish code:


```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Untitled Document

[B]Series:[/B]

[TABLE]
    [TR]
      [TD]
      [/TD]
      [TD]Option 1[/TD]
    [/TR]
    [TR]
      [TD][/TD]
      [TD]Option 2

            --Select a Series--

      [/TD]
    [/TR]
    [TR]
      [TD][/TD]
      [TD] Option 3

      [/TD]
    [/TR]
[/TABLE]
```
When tested, it works, but not exactly how I want it. You can see going from option 1, to 2, and then back to 1 results in the menu next to 2 being active, even when it's not supposed to. Also, it's coded very badly- but all I care about is functionality.

I appreciate any help you guys can offer or any links you can point me toward. I've been googling all night but can't find exactly what I'm looking for.


----------



## Gibbs (Feb 28, 2005)

You could use something like this instead

```
Test

[TABLE]
    [TR]
	[TD]

	[/TD]
	[TD]Option 1[/TD]
    [/TR]
    [TR]
	[TD][/TD]
	[TD]Option 2

		--Select a Series--

	[/TD]
	[/TR]
	[TR]
	[TD]
		[/TD]
	[TD] Option 3

	[/TD]
	[/TR]
[/TABLE]
```


----------

