p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP Forms (http://p2p.wrox.com/forumdisplay.php?f=66)
-   -   How to disable html Form instead Form Elements (http://p2p.wrox.com/showthread.php?t=3066)

hrishimusale August 22nd, 2003 06:47 AM

How to disable html Form instead Form Elements
 
hi guys is it possible to disable all form element once?
i mean can i disable form directly instead form elements so that
all form elements inside form will disable?

Thanks in advance
hrishikesh



planeswalk August 24th, 2003 01:41 AM

Hi,

You can't put a "disabled" attribute in the form tag but you can put the following into your code and call it using the body tag's onLoad event.

<script language="Javascript">
  function disable() {
    var limit = document.forms[0].elements.length;
    for (i=0;i<limit;i++) {
      document.forms[0].elements[i].disabled = true;
    }
  }
</script>

Cheers!


Marlon Villarama
Support Team
Web Burner Hosting
marlon@webburner.com
www.webburner.com
Toll-Free: 877-535-2876

GayatriG2002 April 27th, 2004 01:48 PM


What if I want to disable it on some condition.
Can anyone please let me know how we can do it
ie if a flag is true then disable the whole form
else no.

Thanks,
Gayatri

Gayatri

Snib April 27th, 2004 01:53 PM

Gayatri,

It is possible to assign the function to an event. Just include the function posted by Marlon and assign it to an event like this:

document.onclick = disable;

Let me know if there is a different kind of condition you mean.

HTH,

Snib

<><


All times are GMT -4. The time now is 07:03 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.