Jump to content

Disabling a field based on radio button selection.


iPixel

Recommended Posts

Am i doing something wrong?

 

2 Radio Buttons...

 

<input type="radio" name="form_status" id="form_status" value="Active" onchange="ETDF(this)" /> Active
<input type="radio" name="form_status" id="form_status" value="InActive" onchange="ETDF(this)" /> InActive

 

So if "Active" is selected... the field form_termdate has to be disabled, otherwise if InActive is selected the form_termdate field (textbox) has to be enabled.

 

my JS.

 

<script type="text/javascript">
if(document.getElementById("form_status") == "Active")
{
	document.getElementByID("form_termdate").disabled = true;
}

function ETDF(action) // Enable Terminated Date Field
{
	if(action == "Active")
		{
			document.getElementByID("form_termdate").disabled = true;
		}
	else if(action == "InActive")
		{
			document.getElementByID("form_termdate").disabled = false;
		}
}
</script>

 

Thanks for the help!

Link to comment
Share on other sites

okay.... are you getting any error messages? have you checked the javascript error console in firefox? it could be that it's tripping on the first if() as well, where you check the object itself against a value, rather than the object's value property.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.