PDA

View Full Version : runtime en/dis abling textboxes


tttony
03-26-2001, 05:18 PM
Hi all,

I am trying to enable / disable a series
of text boxes (readonly) at runtime...

does anyone have a hook for this???


thanks
tony

Dr. Web
03-26-2001, 08:29 PM
Try this.

<html>
<title>otui</title>
<script language="javascript">
//this function disables a field for netscape
function skip(){ this.blur(); }
</script>
<FORM NAME="formName" method="">
<input type="text" name="aTextField" length="10" value="something">
</form>
<A HREF="javascript:document.formName.aTextField.onfocus = skip; void
(0)">disable text field</A>
<A HREF="javascript:document.formName.aTextField.onfocus = null; void
(0)">enable text field</A>
</body>
</html>

tttony
03-27-2001, 07:46 AM
Thanks for all your help!!!

This code fragment solved it perfectly.....

here is the summary of implementation....


function skip()
{
this.blur();
}

function getRadioValue (radioButtonOrGroup)
{
var value = null;
if (radioButtonOrGroup.length)
{
for (var b = 0; b < radioButtonOrGroup.length; b++)
if (radioButtonOrGroup[b].checked)
value = radioButtonOrGroup[b].value;
}
else if (radioButtonOrGroup.checked)
value = radioButtonOrGroup.value;
return value;
}





function enable_email_fields()
{
var holder;
holder = getRadioValue(document.form1.internet);
if (holder == "NO")
{
document.form1.email1.value = "n/a";
document.form1.email2.value = "n/a";
document.form1.email3.value = "n/a";
document.form1.email4.value = "n/a";
document.form1.email5.value = "n/a";
document.form1.email1.onfocus = skip;void(0);
document.form1.email2.onfocus = skip;void(0);
document.form1.email3.onfocus = skip;void(0);
document.form1.email4.onfocus = skip;void(0);
document.form1.email5.onfocus = skip;void(0);
}
else
{
document.form1.email1.value = "";
document.form1.email2.value = "";
document.form1.email3.value = "";
document.form1.email4.value = "";
document.form1.email5.value = "";
document.form1.email1.onfocus = null;void(0);
document.form1.email2.onfocus = null;void(0);
document.form1.email3.onfocus = null;void(0);
document.form1.email4.onfocus = null;void(0);
document.form1.email5.onfocus = null;void(0);
}
}


Thanks again

take care
tony

Dr. Web
03-27-2001, 01:12 PM
sure. Glad to be of help.