Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    disabling radio buttons and checkboxes in netscape

    Hi,

    I would like to disable radio buttons and checkboxes in a page.

    disabled="true" works only in IE. I want somehting similiar to that for Netscape. Any work around will do which will disable the radio buttons and checkbox.

    Thanx in advance

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This sample page should get you started:

    BTW, you should say NS4 when you mean that decrepit antique that is Netscape 4. Saying just NS would refer to the current version of Netscape which does support the disabled property for form fields.

    Code:
    <html>
    	<head>
    		<script>
    			function disableField(myField)
    				{
    				myField.disabled = true
    				return true
    				}
    			function enableField(myField)
    				{
    				myField.disabled = false
    				return true
    				}
    			function onfocusField(myField)
    				{
    				if (myField.disabled) 
    					{
    					myField.blur()
    					return false
    					}
    				return true;
    				}
    			// The above functions are generic, the following function is specific to this page	
    			function toggleFields(myField)
    				{
    				if (myField.checked)
    					{
    					disableField(document.forms["example1"].text1)
    					disableField(document.forms["example1"].checkbox1)
    					disableField(document.forms["example1"].select1)
    					}
    				else
    					{
    					enableField(document.forms["example1"].text1)
    					enableField(document.forms["example1"].checkbox1)
    					enableField(document.forms["example1"].select1)
    					}
    				document.forms["example1"].text1
    				}
    		</script>
    	</head>
    	<body>
    		<form name="example1">
    			Disable Fields: <input type="checkbox" name="control1" onclick="toggleFields(this)" checked="checked">
    			<br>
    			Text Field: <input type="text" name="text1" onfocus="return onfocusField(this)">
    			<br>
    			Check box: <input type="checkbox" name="checkbox1" onfocus="return onfocusField(this)" onclick="return onfocusField(this)">
    			<br>
    			Select: <select name="select1" onfocus="return onfocusField(this)">
    				<option></option>
    			</select>
    		</form>
    		<script>
    			disableField(document.forms["example1"].text1)
    			disableField(document.forms["example1"].checkbox1)
    			disableField(document.forms["example1"].select1)
    		</script>
    	</body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •