Link to home
Start Free TrialLog in
Avatar of Slim81
Slim81Flag for United States of America

asked on

Disable textfield with checkbox

Hey guys and gals,
I am pretty new to javascript so please bear with me.

I have a checkbox that when clicked, I would like to disable a textfield.

Here is my function:
<script type="text/javascript">
function disableForm()
{
	if (document.getElementById("fShipping").checked)
	{
		document.getElementById("freeLimit").disabled=true;
	}
}	
</script>

Open in new window


And here is my HTML:
<p id="freeShipping">
  <input name="fShipping" id="fShipping" type="checkbox" value="1" onFocus="disableForm()"/> 
  Free shippping on all orders over $
  <input name="freeLimit" id="freelimit" type="text" size="6" maxlength="6" />
</p>

Open in new window


Any ideas would be greatly appreciated!

Thanks,
Slim
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Slim81

ASKER

Right on.

Thanks!