Home > Enterprise >  form-select not sending data
form-select not sending data

Time:01-14

I dont see the reason why one particular html field is not sending data.

My html:

<form  id="login_registro_form" role="form" method="post" action="./controllers/register.php">
        <div >
            <label  for="regName">NOMBRE</label>
            <input type="text"  id="regName" placeholder="SEGÚN APARECE EN EL DNI/PASAPORTE" name="regName">
            <div >El nombre es un campo obligatorio </div>
        </div>
       <div >
            <label  for="reg_birthday">CONFIRMA TU TALLA</label>
            <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 >
                <label for="reg_allergies">ALERGIAS, INTOLERANCIAS O DIETAS ESPECIALES</label>
                <input type="checkbox"  id="reg_allergies" name="allergies" >
        </div>          
        <button id="register_button" type="submit"  >GUARDAR</button>
    </form>

While this is shortened all the other imput fields are working and enclosed within the same div

In my php i tried checking with:

 var_dump($_POST);die;

I am able to see there that ALL of the other variables are there except the options And one more thing. I have some validations before i send the information:

$('#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 );
    });

So the information IS there just before posting it, but for some reason it is not being recognised as part of the form

Edit: I know i can retrieve the information using jquery and send it it by creating a new field, but im trying to understand my html mistake here.

CodePudding user response:

You have not given the <select> element a name="talla" attribute, Therefore it is not sent to the PHP code. Only fields with a name= attribute can send data to PHP Code.

  •  Tags:  
  • Related