0

I am working on online exam system in the answer sheet i have RadioButton I have four radio buttons for each question and i want to return the value of 0 when none of them are selected

  • this may hlep - http://stackoverflow.com/questions/14747803/how-to-send-radio-button-value-in-php – Caffeinated Sep 14 '14 at 23:13
  • 1
    If none of them are selected, the radio button won't be accessible in the `POST` superglobal, you could check in php if it is set when processing otherwise mark it as `0`. – Darren Sep 14 '14 at 23:15

2 Answers2

0
<?php echo isset($_REQUEST['this_button']) ? $_REQUEST['this_button'] : '0' ?>

this will set it to 0 if nothing is selected

There's also this interesting read about whether you should have a value in a radio button preselected or not. So consider having a hidden radiobutton element whose value is 0 and is preselected

J-Dizzle
  • 3,176
  • 6
  • 31
  • 49
0

You need to have five RadioButtons, one of them should have the value of 0 and should be invisible. That should be selected on default.

Darren
  • 13,050
  • 4
  • 41
  • 79
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175