douyue9704 2019-04-21 21:07
浏览 49
已采纳

Textarea元素不会使用POST返回任何值

I'm trying get the value from textarea, but the form doesn't send the textarea value.

I tried adding a name attribute to textarea, also a form attribute with the form id but it still doesn't send any value and I don't know why. How do I solve this problem?

<form id="form-formulario_incidencia" method="POST" action="./nuevaIncidencia.php">
    <div class="form-group row">
        <label for="form-titulo" class="col-sm-2 col-form-label">
            Título: 
        </label>
        <div class="col-sm-10">
            <input type="text" id="form-titulo" name="titulo" class="form-control" required="" readonly="">
        </div>
    </div>
    <div class="form-group row">
        <label for="form-descripcion" class="col-sm-2 col-form-label">
            Descripción: 
        </label>
        <div class="col-sm-10">
            <textarea class="form-control" id="form-descripcion" name="descripcion" rows="3" required="" form="form-formulario_incidencia" disabled=""></textarea>
        </div>
    </div>
    <div class="form-group row">
        <label for="form-lugar" class="col-sm-2 col-form-label">
            Lugar: 
        </label>
        <div class="col-sm-10">
            <input type="text" id="form-lugar" name="lugar" class="form-control" required="" readonly="">
        </div>
    </div>
    <div class="form-group row">
        <label for="form-palabras_clave" class="col-sm-2 col-form-label">
            Palabras Clave: 
        </label>
        <div class="col-sm-10">
            <input type="text" id="form-palabras_clave" name="palabras_clave" class="form-control" readonly="">
        </div>
    </div>
    <div class="form-group row">
        <div class="col-sm-2"></div>
        <div class="col-sm-10">
            <input type="submit" value="Confirmar la inserción" class="btn btn-primary mb-2" onclick="enviarFormularioIncidencia()">
        </div>
    </div>
</form>

This is what var_dump($_POST); returns:

array(3) {
  ["titulo"]=>
  string(8) "Prueba 1"
  ["lugar"]=>
  string(6) "London"
  ["palabras_clave"]=>
  string(0) ""
}
</div>
  • 写回答

1条回答 默认 最新

  • dpfln86244 2019-04-21 21:12
    关注

    Your textarea element contains the disabled attribute. Even though it's set to an empty value, its presence alone signifies a disabled form element and the browser will not send it.

    From the HTML 5 spec, on boolean attributes:

    A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

    If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

    The same goes for the readonly attribute on the elements as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?