Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form will not submit with disabled field

Status
Not open for further replies.

kiwieur

Technical User
Apr 25, 2006
200
GB
Hi,

I was under the impression that if a field was disabled the form would still submit all the other fields data but not the disabled field.

Am i correct in assuming that ?

The reason I ask is that I have a form that has fields disabled if certain criteria is met such as the following code

Code:
<script language = "javascript">
		function CheckSelect() {
            var Print = document.getElementById("txtPrintNo").value.length;
            var disableSelect = false;
            if (Print <2) disableSelect = true;
			document.forms['frmEnterRecord'].elements['selSwatch'].disabled = disableSelect;
			document.forms['frmEnterRecord'].elements['selLayout'].disabled = disableSelect;		
        }
    </script>

however if I try and submit the form with the fields disabled then I get an HTTP 500 error.

however if the fields are not disabled the form values get submitted OK.

does anyone have any ideas




Regards

Paul

 
you are correct that disabled fields wont be submitted, one option if you do want the data sent but not messed with on the user side is hidden elements or read-only elements

a common practicei've seen for submit buttons is to disable the button via JS when clicked so that it cant be re-submitted, another is to read-only all form elements on submit plus disable the submit, it prevents last second changes.

lastly is to make a float div that spans 100% x 100% with click disablers, everything is visible on the page, but nothing is able to be clicked or used, almost like putting a piece of digital glass over the form display

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
try using hidden fields...I know its more work but its one way to get around the disabled form fields...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top