[thelist] Disable Multiple Forms with JavaScript

Mike Carlson mike at mcarlson.net
Wed Aug 4 07:36:21 CDT 2004


Peter:

My bad. I missed the var currentForm; line. It's working fine now.

We use IE here but I test in Mozilla because it has a JavaScript console which has better reporting than IE's crap. For some reason Mozilla didn't mind that currentForm was not declared before using it. I may have to send that one to the Mozilla group.

Thanks for your help!

--Mike Carlson
mike at mcarlson.net
http://www.uselessthoughts.com




From: Peter Brunone (EasyListBox.com)
Sent: Tue 8/3/2004 10:56 PM
To: thelist at lists.evolt.org
Subject: RE: [thelist] Disable Multiple Forms with JavaScript


Mike,

	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).

Peter

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

Peter:

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.

Thanks,
--Mike


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
	for(var
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.

Cheers,

Peter Brunone
---------------------------------
Do the impossible.  Go home early.
www.EasyListBox.com
---------------------------------

-----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.

Thanks,
--Mike


-- 
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 


More information about the thelist mailing list