Page 1 of 1

Disabled HTML textbox not posting

Posted: Thu Aug 30, 2007 9:46 am
by impulse()
I've been crawling through code to find an error which turned out to be a disabled text box not posting its data. Surely there's a way to make it post data? This is a simple script I used to test if it works, but it doesn't:

Code: Select all

<
form method = 'post'>
  <input type = 'text' name = 'disabledBox' value = 'Filled in disabled box' disabled>
  <input type = 'text' name = 'enabledBox'>
  <input type = 'submit' value = 'Shoot'>
</form>

<?php

if($_POST)
  print_r($_POST); 

?>
But this only posts the data from the text box that's enabled.

Regards,

Posted: Thu Aug 30, 2007 10:06 am
by mcog_esteban
try instead of disabled: readonly

Posted: Thu Aug 30, 2007 10:27 am
by Steve Mellor
Or, if the user doesn't need to see the input, use a hidden field.

Posted: Thu Aug 30, 2007 10:41 am
by Kieran Huggins
you need to enable the field if you want it to post - might I suggest a snippit of jQuery to re-enable all fields on submit?

Posted: Thu Aug 30, 2007 12:15 pm
by impulse()
The readonly attribute worked a treat.


Thanks.