Submitting the value of a disabled input field

前端 未结 4 1132
执念已碎
执念已碎 2020-12-23 02:30

I want to disable an input field, but when I submit the form it should still pass the value.

Use case: I am trying to get latitude and longitude from Google Maps and

4条回答
  •  情话喂你
    2020-12-23 03:09

    I know this is old but I just ran into this problem and none of the answers are suitable. nickf's solution works but it requires javascript. The best way is to disable the field and still pass the value is to use a hidden input field to pass the value to the form. For example,

    
    
    

    This way the value is passed but the user sees the greyed out field. The readonly attribute does not gray it out.

提交回复
热议问题