• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to disable a form

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I want a page where there's a radio button on the top and disabled form (all the fields in the form greyed on so you can't type on it) but if a radio button in checked then the form should be enabled(now you can type on it). Could someone please tell me how to do that. I'm a newbie in javascript. I would appreciate all the help. Thanks.

Mala
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This shows you how to disable the form elements
[url]http://radio.javaranch.com/pascarello/2005/05/17/1116340367337.html[url]

But we need to change the script around and since I am being nice today:
[code]
var xForm;
function DisableEnableForm(){
objElems = xForm.elements;
for(i=0;i<objElems.length;i++){
objElems[i].disabled = xForm.radioName[0].checked;
}
xForm.radioName[0].disabled = false; //can not disable
xForm.radioName[1].disabled = false; // you radio buttons!

}

window.onload = function(){
xForm = document.formName;
DisableEnableForm()
xForm.radioName[0].onclick = DisableEnableForm;
xForm.radioName[1].onclick = DisableEnableForm;
}
[code]


Hopefully you can figure out how to add your radio Names buttons and change the formName in the script.

Eric
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic