Help us understand the problem. What is going on with this article?

disabled属性とreadonly属性の相違点

両方とも値を編集できないという点は共通していますが、以下の点が異なります。

Form送信時
disabled:値を送信しない
readonly:値を送信する

要素内のテキスト選択=表示値の選択、コピー
disabled:選択不可
readonly:選択可

選択はさせたくないけど値を送信したい場合、readonly属性を設定したタグをCSSでそれっぽく見せるより、
disabled属性を設定したタグと同じ値をhiddenタグにもたせるのが一番スマートな解決策だと思います。

<input type="text" disabled="disabled" value="10" />
<input type="hidden" name="test" disabled="disabled" value="10" />

特定のtable内の集計値が欲しく、集計用のinputタグにdisabledを設定していた時に、値が送信されずに困りましたので、メモです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした