[thelist] Disable Multiple Forms with JavaScript

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Tue Aug 3 22:56:39 CDT 2004


	Where is the error occurring?  What's the offending line of
code?  The sample below works fine for me with multiple forms in IE6
(with text and button inputs).


-----Original Message-----
From: thelist-bounces-evolt=easylistbox.com at lists.evolt.org On Behalf Of
Mike Carlson


Thanks for the code. I am running into a problem though. It works
perfectly in FireFox .9 but not in IE 6. I get some JS error about
Object Expected in IE.

Any ideas? I fixed the wrap but otherwise the code is exactly the same.
Like I said it works in Mozilla just fine. I have no image input type,
just text boxes and buttons.


From: Peter Brunone (EasyListBox.com)

Hi Mike,

	Something like this should work (watch for wrapping):

var currentForm;

for(var iForm=0;iForm<document.forms.length;iForm++) {
	currentForm = document.forms[iForm];
	/* I assume this is how you disable a form, 
        if such a thing can be done. */
	currentForm.disabled = true;
	// The next line will probably wrap
iElement=0;iElement<currentForm.elements.length;iElement++) {
		currentForm.elements[iElement].disabled = true;

	Note that this may not affect input elements of type image; you
may have to do that some other way.  Also note that "disabled" is hardly
a ubiquitous attribute in older browsers; you may have to add some extra
Javascript like 

	currentElement.onFocus = "window.focus";

	The idea here is to set the focus somewhere else so the user can
never stay on an element long enough to do anything.  Anyhoo, this
should get you started; if you have more questions, fire away.


Peter Brunone
Do the impossible.  Go home early.

-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Mike Carlson

Anyone have any code that will disable all forms and all form elements
of said forms?

I have a page that has a few forms on it and I need to disable
everything on the page so the user cannot make any changes.


More information about the thelist mailing list