PDA

Click to See Complete Forum and Search --> : Disabling Input Elements


CiberTHuG
May 16th, 2001, 05:08 PM
I am not finding a way to do this, so it may not be possible, but...

I have two radio buttons and a series of text fields. If you radio A, it ignores the text fields, if you radio B, it uses the text fields. Ofcourse, "it" being the ASP that will parse the Request.Form() data.

My question is, is there a way that JavaScript can manually disable the text fields on radio A's click() event? Ofcourse, I would need to be able to enable them on radio B's event, but I imagine if one is possible, the other is, too. By disabling, I'm looking for some way to lock them, or grey them out, to keep the user from inputing anything into them.

Wynd
May 16th, 2001, 05:23 PM
Maybe something like:


<script>
if (document.a.b.value != "") //null maybe?
document.a.b.value = "";
</script>

<form name="a">
<input type="text" name="b">
</form>


You can physically disable form elements by adding "disabled" to the list of attributes:

<textarea rows="5" disabled></textarea>

but this won't work in Netscape.

CiberTHuG
May 16th, 2001, 06:39 PM
Yes, but I'm not sure if you can...


<html>
<head></head>
<body>
<form name='myForm'>
<input name='myInput'>
</form>
<script language='JavaScript'>
function DisableEm() {
document.forms[0].elements[0].disable = true;
}
</script>
</body>
</html>


Know what I mean? I haven't tried the above code because the Rhino book doesn't list disable as a method or property of the input element.