How to solve the problem of not getting form value after submitting html form input using disabled

How to solve the problem of not getting form value after submitting html form input using disabled

After the form input box input is set to the disable attribute and submitted, the value of the input box cannot be obtained. To solve this type of problem, you can refer to the following two methods:

Method 1:

Use readonly instead of disabled, that is,

disabled="disabled"

Modified to

readonly="readonly"

The difference between the two:

Disabled cannot receive focus and will be skipped when the tab key is used, which may not be successful;
Readonly can receive focus but cannot be modified. You can use the tab key to navigate, which may be successful.
Note: Only successful form elements are valid data, that is, values ​​can be obtained after submission. The value attribute of disabled and readonly text input boxes can only be modified through scripts.

Method 2:

Use type=hidden to hide the input to get the value, and then use disabled to show the input to the user.

<input type="hidden" name="url" value="http://www.neirong.org"/>
<input type="text" value="http://www.neirong.org" disabled="disabled"/>

Summarize

The above is the solution that I introduced to you when the HTML form input cannot obtain the form value after submitting it with disabled. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  Summary of JavaScript Timer Types

>>:  Details of the underlying data structure of MySQL indexes

Recommend

Detailed explanation of how to implement secondary cache with MySQL and Redis

Redis Introduction Redis is completely open sourc...

How to Monitor Linux Memory Usage Using Bash Script

Preface There are many open source monitoring too...

How to install docker on ubuntu20.04 LTS

Zero: Uninstall old version Older versions of Doc...

How to monitor Windows performance on Zabbix

Background Information I've been rereading so...

How to use css variables in JS

How to use css variables in JS Use the :export ke...

Docker learning: the specific use of Container containers

Container is another core concept of Docker. Simp...

How to query duplicate data in mysql table

INSERT INTO hk_test(username, passwd) VALUES (...

Solution to the inconsistency between crontab execution time and system time

Preface In LINUX, periodic tasks are usually hand...

The pitfalls of deploying Angular projects in Nginx

Searching online for methods to deploy Angular pr...

Detailed tutorial on installing Docker on CentOS 7.5

Introduction to Docker Docker is an open source c...

JavaScript implements displaying a drop-down box when the mouse passes over it

This article shares the specific code of JavaScri...

A detailed account of the process of climbing a pit of Docker deployment service

First time writing. Allow me to introduce myself....

One line of CSS code to achieve the integration of avatar and national flag

It’s National Day, and everyone is eager to celeb...

Detailed explanation of the use of umask under Linux

I recently started learning Linux. After reading ...