I have a form that displays two radio buttons (using PHP).
echo "<form action=\"next.php\" method=\"post\">";
echo "<input type=\"radio\" name=\"paid\" value=\"0\" checked=\"checked\">No<br>";
echo "<input type=\"radio\" name=\"paid\" value=\"1\">Yes<br>";
echo "</form>";
One of the radio buttons is always checked by default. If the user checks the other radio button, I would like the form to submit itself (without the user having to click a submit button).
you can append this into your input:
onchange='this.form.submit();'
like:
echo "<form action=\"next.php\" method=\"post\">";
echo "<input onchange='this.form.submit();' type=\"radio\" name=\"paid\" value=\"0\" checked=\"checked\">No<br>";
echo "<input onchange='this.form.submit();' type=\"radio\" name=\"paid\" value=\"1\">Yes<br>";
echo "</form>";
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With