1
    echo    "<form class='custom'>";
foreach ($prices->item as $item){
      $ongkir = $item->value;
      $transfer = $total_jne * 1000;
      $transfer_rp = $transfer + $ongkir;
      $jne = $item->service;
      $checked = ($jne == $_POST['ongkir'])? ' checked="checked"' : '';
      echo  "<tr><td><label for='$item'>
      <input class='custom' name='ongkir' $checked type='radio' id='ongkir'> $jne</label></td>";
      echo  "<td>Rp. $ongkir</td>";
      echo  "<td>Rp. $transfer_rp</td></tr>";}
      echo  "</table><hr></form>" ;
    }

大家好,我如何使用 value='$transfer_rp' 将“已检查”发布到另一个带有按钮的 php 文件?:(

4

1 回答 1

1

无线电输入将作为“真”或“假”出现,而不是作为其名称属性的值,所以试试

$checked = ($jne == 'ongkir' && isset($_POST['ongkir']) && $_POST['ongkir'] == "true" )? ' checked="checked"' : '';

或者,因为这很难看

$checked = '';
if( $jne == 'ongkir' && isset($_POST['ongkir']) && $_POST['ongkir'] == "true" ){
    $checked = 'checked="checked"';
}
于 2013-03-31T23:26:41.130 回答