Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!