1

This is how the disabled attribute works. When a form control is disabled, the value will be ignored when the form is submitted and the key will not be present in $_POST (or $_GET).

If you want the value to be present in the submitted data, but you don't want the user to be able to change the value on the page (which I imagine is what you are trying to acheive) use readonly="readonly" instead of disabled="disabled".

EDIT

The <select> element does not have a readonly attribute. The above information still stands as it will work for <input>s and <textarea>s.

The solution to your problem here would be to disable the select and use a hidden input to send the value back to the server - e.g.

When the select is enabled:

<select class="txtbx1" name="country">
  <!-- options here -->
</select>

...and when it is disabled:

<select class="txtbx1" name="country_disabled" disabled="disabled">
  <!-- options here, with appropriate value having `selected="selected"` -->
</select>
<input type="hidden" name="country" value="value_of_field" />

But the main thing is that how to set these Hidden field when i change the Select field . and how to set at Submit form time . ?

Ajinkya Kasar
  • 23
  • 1
  • 6

1 Answers1

0

Hope This might help you,

HTML form readonly SELECT tag/input

Further you should use jQuery in order toggle Disabling the select tag and assigning new values to hidden field. Initially you should use PHP echo attribute to set your hidden field Value.

Community
  • 1
  • 1
Rohit Nigam
  • 708
  • 8
  • 23