【发布时间】:2022-01-13 10:10:41
【问题描述】:
我看不出某个特定 html 字段不发送数据的原因。
我的html:
<form id="login_registro_form" role="form" method="post" action="./controllers/register.php">
<div class="row my-4 justify-content-md-center">
<label class="col-lg-3" for="regName">NOMBRE</label>
<input type="text" class="form-control" id="regName" placeholder="SEGÚN APARECE EN EL DNI/PASAPORTE" name="regName">
<div class="invalid-feedback ">El nombre es un campo obligatorio </div>
</div>
<div class="row my-4 justify-content-md-center">
<label class="col-lg-3" for="reg_birthday">CONFIRMA TU TALLA</label>
<select class="form-select" id="talla" nombre="talla" aria-label="Default select example">
<option value="xs">XS</option>
<option value="s">S</option>
<option value="m" selected>M</option>
<option value="L">L</option>
<option value="xl">XL</option>
<option value="xxl">XXL</option>
</select>
</div>
<div class="login_cb justify-content-md-center">
<label for="reg_allergies">ALERGIAS, INTOLERANCIAS O DIETAS ESPECIALES</label>
<input type="checkbox" class="form-check-input " id="reg_allergies" name="allergies" >
</div>
<button id="register_button" type="submit" class="btn btn-primary" >GUARDAR</button>
</form>
虽然这已缩短,但所有其他输入字段都在工作并包含在同一个 div class="row my-4 justify-content-md-center"
在我的 php 中,我尝试检查:
var_dump($_POST);die;
我可以在那里看到除了选项之外的所有其他变量 还有一件事情。在发送信息之前,我有一些验证:
$('#login_registro_form').submit(function(e) {
//My validations for the rest of the form
console.log($('#talla').val()); //THIS IS ACTUALLY SHOWING THE INFORMATION
return (errores.length <= 0 );
});
所以信息在发布之前就在那里,但由于某种原因它没有被识别为表单的一部分
编辑:我知道我可以使用 jquery 检索信息并通过创建一个新字段来发送它,但我试图在这里理解我的 html 错误。
【问题讨论】:
-
你没有给那个
-
好的,nombre 是西班牙语中的名字。现在我得到了错字。谢谢
-
您的选择元素需要一个名称属性。你的是用西班牙语“名词”写的,应该是英文的
name。
标签: php html jquery forms bootstrap-5