Microsoft KB Archive/287738

= PRB: Disabled Form Elements Are Not Submitted =

Article ID: 287738

Article Last Modified on 5/10/2003

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q287738



SYMPTOMS
When you submit an HTML form that contains disabled elements, the disabled elements are not submitted with the rest of the form elements. In addition, in your server-side form processing code, you may not receive name/value pairs for any disabled elements that are located on your form.



CAUSE
According to the World Wide Web Consortium (W3C) HTML specifications, disabled elements cannot be considered &quot;successful&quot;, and only &quot;successful&quot; elements are submitted with a form.



RESOLUTION
To submit the values of disabled elements, you must either enable the disabled elements or programmatically create new elements with the same name that submit the values of the disabled element.



MORE INFORMATION
The following sample code illustrates how to programmatically create new elements to submit the values of disabled elements through script in Internet Explorer 5.0 or later:    function doSubmit(theForm) {   var i = 0; for (i = 0; i < theForm.elements.length; i++) {       if (theForm.elements[i].tagName == &quot;INPUT&quot; && theForm.elements[i].type == &quot;text&quot;) {           if (theForm.elements[i].disabled == true) {                  var newElement; newElement = document.createElement(&quot;INPUT&quot;); newElement.type = &quot;hidden&quot;; newElement.name = theForm.elements[i].name; newElement.value = theForm.elements[i].value; theForm.appendChild(newElement); newElement = null; }       }    }

return true; } 

 First Name:  Last name:   </FORM>

</BODY> </HTML>

<div class="references_section">