Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Controls

Status
Not open for further replies.

FRANDAZZO

Programmer
Nov 29, 2000
60
US
Hello all ,
Question - I have to disable some html controls. Not a problem in I.E. but they do not disable in Netscape. Basically I have a function and I call it in the onLoad of the body tag. In the funcion I have the following code:

function FormLoad()
{
document.frmQuestion.rdoCML[0].disabled = true //radio
document.frmQuestion.rdoCML[1].disabled = true
document.frmQuestion.rdoCML[2].disabled = true
document.frmQuestion.rdoCML[3].disabled = true
document.frmQuestion.cboDose.disabled = true //drop down
document.frmQuestion.cboFrequency.disabled = true
document.frmQuestion.cboLength.disabled = true
}//end function

How do I make this work in Netscape.......

Thanks,
Frandazzo
 
Sorry don't know an easy way to make it work in Netscape.

But you could put code in the onClick of each control (to reset the value after the user clicks the control). That would work in both, but is probably more painful.

Sorry...
Jay
 
Use the "onFocus=blur" trick.

<html>
<head>
<title>Test</title>
<script language=&quot;JavaScript&quot;><!--
function disable(elem) { // elem: form element to be disabled
elem.onfocus=elem.blur;
}
function enable(elem) { // elem: form element to be reenabled
elem.onfocus=null;
}
//--></script>
</head>
<body>
<form>
<input type=&quot;text&quot; name=&quot;myTextBox&quot;>
<input type=&quot;button&quot; value=&quot;Disable&quot; onClick=&quot;disable(this.form.myTextBox)&quot;>
<input type=&quot;button&quot; value=&quot;Enable&quot; onClick=&quot;enable(this.form.myTextBox)&quot;>
</form>
</body>
</html>


br
Gerard
(-:

Better a known bug then a new release.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top