Monday, October 19, 2015

Post Values from Uneditable input fields

Sometimes you want to set the data of an input field through JQuery and at the same time you need that field to be uneditable, then the workaround is to add the attribute 'readonly' to that field. Being 'readonly' makes the field uneditable and the form will submit the value as well whereas the attribute 'disabled' makes the field uneditable but the form will not submit the value.

Example:
<input name="un_editable_field" type="text" readonly />

Now you can get the values normally in the action file
$value = $_POST['un_editable_field'];

No comments: