How can I get the clicked button value when its name is echoed by PHP?
Here's my code:
<form>
<input type='radio' name=<?php echo $i; ?> id='choice1' value=<?php echo $row['choices_a']; ?> checked/>
<?php echo '' .$row['choices_a']. '' ?>
<input type='radio' name=<?php echo $i; ?> id='choice2' value=<?php echo $row['choices_b']; ?> />
<?php echo ''.$row['choices_b'].''?>
<input type='radio' name=<?php echo $i; ?> id='choice3' value=<?php echo $row['choices_c']; ?> />
<?php echo ''.$row['choices_c'].''?> <br />
</form>
<?php
} echo $total;
?>
You can get value of that radio button is just simply like other inputs
$_POST['input_name']
And in your case if i = input_value
,
$total = $_POST['input_value'];
echo $total;
You can Also check if that is clicked or isset
if(isset($_POST['input_value'])){
$total = $_POST['input_value'];
echo $total;
}
Hope it clears.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.