• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to disable all form elements

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How To disable all form elements while clicking a button..
Thanks in Advance
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aravind JAI:
How To disable all form elements while clicking a button..
Thanks in Advance



Try this function:

function disable() {
for(var i=0; i<formnames.length;i++) {
formElements = formnames[i].elements;
for(var j=0; j<formElements.length;j++) {
document.formnames[i].formElements[j].disabled = true;
}
}
}

And call this function onclick of button.
 
Aravind JAI
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It gives error like, formNames is undefined..
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I missed few things.


Can you try this function:

function disable() {
var formnames = document.forms;
var formElements = new Array();

for(var i=0; i<formnames.length;i++) {
formElements = formnames[i].elements;
for(var j=0; j<formElements.length;j++) {
document.formnames[i].formElements[j].disabled = true;
}
}
}

And call this function onclick of button.
 
Aravind JAI
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Very Much Friend..Can i have Your Mail-id
 
Aravind JAI
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again i am getting error message..document.forms is null or not an object
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this simple function

function disablefunction() {
for(var i=0; i<document.forms[0].length;i++) {
document.forms[0].elements[i].disabled = true;
}
}
 
Aravind JAI
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks it is working fine..Please give ur mail id
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aravind JAI:
Thanks it is working fine..Please give ur mail id



The above solutions also should work with minor changes. They are most generic solutions. I will send you a PM with my email id.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://radio.javaranch.com/pascarello/2005/05/17/1116340367337.html

Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic