Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
php returns undefined array key when I POST radio buttons

I have this html code:

    <form method="POST" action="location/files/myscript.php">
      <input type="radio" name="choice" value="ex1">
      <input type="radio" name="choice" value="ex2">
      <button type="button" id="print">
    </form>

I know there is no submit button, but I send a request with ajax like this:

$('#print').on('click', () => {
request = $.ajax({
            url: "location/files/myscript.php",
            type: "POST",
            data: dataD
        });
}

And my php file looks like this:

$choice = $_POST['choice'];

if($choice == 'ex1') {
   echo "yes";
} else {
   echo "no";
}

I tried with isset and empty too, but I still get Undefined array key "choice"

EDIT: no, I don't want the warning just to disappear. The problem is that I select a radio button and it is still returning that warning. I want it to work, not no hide the warning

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda