F
F
feniksdv2018-03-09 06:43:06
PHP
feniksdv, 2018-03-09 06:43:06

How to make a field with type radio remain selected after page refresh?

I've been fighting for the second day without success. Only it is necessary without js / jq and similar things, naked php.

echo '<input type="radio" name="test" value="1">1<br>';
echo '<input type="radio" name="test" value="2">2<br>';
echo '<input type="radio" name="test" value="3">3<br>';
echo '<input type="submit" value="go"><br>';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2018-03-09
@feniksdv

echo '<input type="radio" name="test" value="1" '.($_GET["test"] == 1? "checked":"" ).'>1<br>';
echo '<input type="radio" name="test" value="2" '.($_GET["test"] == 2? "checked":"" ).'>2<br>';
echo '<input type="radio" name="test" value="3" '.($_GET["test"] == 3? "checked":"" ).'>3<br>';
echo '<input type="submit" value="go"><br>';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question