I'm creating a demo page where certain setting fields have to be disabled. I have tried disabling the input with the value remaining intact, just greyed out. I have disabled the inputs using disabled="true". When submitting the form, the value disappears in spite of being there before. How do I prevent the value from disappearing whilst simultaneously disabling the said fields?
If you want the value to be displayed and and not changed , you can use readonly
<input type="text" name="xxx" value="xxx" readonly="readonly" />
If you want the value to be hidden and submitted to the action file you can use type =hidden
<input type="hidden" name="xxxx" value="xxx" />
More about HTML input tag can be found here http://www.w3schools.com/tags/tag_input.asp
disabled
form fields are not submitted under any circumstances.
The most common way to avoid this problem is making them readonly
and adding an input[readonly] { ... }
css rule to make the text gray like in a disabled field.
You might also want to use some JavaScript to prevent it from being focused; could look like this if you have jQuery:
$('input[readonly]').live('focus', function(e) {
$(this).blur();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With