How to disable and enable form fields in php?

Hi all
In one of my form,
They are more than 10 fields to gather info from the user…
I want to put + simple with some text message… if user clicks on it, the remaining fields can display in the same form dynamically (where we put + below it only display remaining fields)

I want your help regarding this…

Thanking you…

Double post?
http://www.sitepoint.com/forums/showthread.php?t=698104

I do not quite understand your requirement here. to disable a form element, you just need to change its disabled attribute to false.


if(some_event_occurred){
    document.formname.element.disable = false; // or true if you want to enable the element.
}

Double posts with two different questions :slight_smile:

This question has been asked in the PHP forum and the answer is to use the JavaScript code Rajug supplied because it can’t be done using PHP.

This can be done using javascript.

Write a function in javascript that will show and hide the form fields on the clikc event.
Like this

function showHide(){
if(document.getElementById(divid).style.display=='none'){
   document.getElementById(divid).style.display='block';
}else{
   document.getElementById(divid).style.display='none';
}

}

If you have multiple section to display than pass a parameter in the function according to your need.

Hope this will help you…