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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。