Reputation: 3
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) ""
}
Upvotes: 0
Views: 110
Reputation: 42713
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.
Upvotes: 3