好吧我正在用$ _POST自己發送數據。
我有一些默認選中的複選框。 (在這個例子中爲1 & 2)
當表格被修改時,我想用$ _POST值覆蓋這些默認值。
<?php
$syndication_check_1 = 'checked="checked"';
$syndication_check_2 = 'checked="checked"';
$syndication_check_3 = '';
if (isset($_POST['syndication'])) {
//
}
?>
<form name="form" method="post" action="">
<!-- this is what I use for radiobuttons -->
<legend>Sex:</legend>
<input type="radio" name="sex" id="sex-1" value="M" <?php echo (!isset($_POST['sex']) || $_POST['sex'] == "M") ? 'checked="checked"': ''; ?> />
<label for="sex-1"><?= _("Male"); ?></label>
<input type="radio" name="sex" id="sex-2" value="F" <?php echo (isset($_POST['sex']) && $_POST['sex'] == "F") ? 'checked="checked"': ''; ?> />
<label for="sex-2"><?= _("Female"); ?></label>
<!-- now something similar for checkboxes -->
<legend>Syndication:</legend>
<input type="checkbox" name="syndication[]" id="syndication-1" value="yahoo" <?= $syndication_check_1; ?> /> <!-- checked -->
<label for="syndication-1">Yahoo Real Estate</label>
<input type="checkbox" name="syndication[]" id="syndication-2" value="trulia" <?= $syndication_check_2; ?> /> <!-- checked -->
<label for="syndication-2">Trulia.com</label>
<input type="checkbox" name="syndication[]" id="syndication-3" value="zillow" <?= $syndication_check_3; ?> />
<label for="syndication-3">Zillow.com</label>
</form>
你的問題是什麼? – Beaker 2010-11-30 08:21:20
是的,它不清楚 – 2010-11-30 08:21:55
我怎樣才能用$ _POST數據值覆蓋我的默認值? – FFish 2010-11-30 08:49:34