我已将收音机输入为:
<input type="radio" name="payvalue" value="126500000"><br>
<input type="radio" name="payvalue" value="252000000"><br>
<input type="radio" name="payvalue" value="503000000" checked><br>
和a href get value to payment as
<a target="_blank" href="https://www.demo.com/button_payment.php?receiver=email@gmail.com&price=GET_VALUE_OF_RADIO">Pay Now</a>
如何将输入收音机get value of check更改为
price=GET_VALUE_OF_RADIO
任何关于HEPS的想法都会让我失望。谢谢
SO网友:Wacław Jacek
首先,让我们将所有“payvalue”无线电选项放入一个数组中。这将允许我们使用foreach
循环以减少冗余和出错的机会:
$payValueOptions = [126500000, 252000000, 503000000];
现在,让我们在
foreach
回路:
$selectedPayValue = $_GET[\'price\'];
foreach ($payValueOptions as $option):
$isChecked = ($selectedPayValue == $option);
?>
<input type="radio" name="payvalue" value="<?php echo $option; ?>" <?php $isChecked ? \'checked\' : \'\' ?>><br>
<?php
endforeach;