|
Subject:
|
disable input elements without using "disabled"
|
|
Posted By:
|
pollockc
|
Post Date:
|
1/20/2006 11:37:14 AM
|
I'm creating a form that the user will print off. When I use the input "disabled" property the boxes become greyed and are very difficult to see when printed out. However, I don't want the user to be able to change the input (and select) form elements on the print page. I'm assuming there has to be a javascript way of disabling the input and select elements without actually using the "disabled" property. Your help would be greatly appreciated!
:: Chris Pollock ::
|
|
Reply By:
|
ChrisScott
|
Reply Date:
|
1/20/2006 11:40:57 AM
|
Hi Chris,
You can use the readonly property to do this.
HTH,
Chris
|
|
Reply By:
|
pollockc
|
Reply Date:
|
1/20/2006 11:48:50 AM
|
I should have been more specific. Really I need to disable radio buttons, checkboxes, and select elements. "readonly" works only with "text".
:: Chris Pollock ::
|
|
Reply By:
|
Greg Griffiths
|
Reply Date:
|
1/23/2006 5:33:49 PM
|
You could create a Javascript function like the following :
var isRO=true; function isFieldRO(this) { if (isRO) { this.blur(); } } <input type=checkbox onfocus="isFieldRO(this)">
|
|
Reply By:
|
pollockc
|
Reply Date:
|
1/24/2006 9:44:32 AM
|
quote: Originally posted by Greg Griffiths
You could create a Javascript function like the following :
var isRO=true; function isFieldRO(this) { if (isRO) { this.blur(); } } <input type=checkbox onfocus="isFieldRO(this)">
Hmmm.. this didn't work either. The Javascript is not "bombing", but it doesn't seem to be disallowing the input. I'm mystified! I think I"m going to try and build a page with nothing else on it and see if it works, but right now all of the suggested options don't seem to do the job.
I do thank you for taking the time to write thought. Any other ideas out there
:: Chris Pollock ::
|
|
Reply By:
|
pollockc
|
Reply Date:
|
1/24/2006 9:51:18 AM
|
OK!!! I figured it out. I needed to include another operation, besides the blur in order for it to work. Here's what I did:
<script language="javascript">
var isRO=true;
function isFieldRO(myelement) {
if(isRO){
myelement.blur();
alert('Sorry, you cannot change this element.');
}
}
</script> I bolded the change that I made. I'm not sure why this is, but it works. Thank you everyone for your help!!
:: Chris Pollock ::
|