我有一个带有一些单选按钮和表单的页面。当我选择一个单选按钮时,我需要将其 id 设置为 $_POST['id'] 变量,因此当我提交表单时,我可以检查选择了哪个单选按钮并采取相应措施。我知道我不能直接这样做,所以尝试使用
onclick="document.getElementById("id").value="'.$row['id'].'"
在单选按钮上,但它不起作用。
$d="select * from {$_c['dbprefix']}card where active='1' order by s_sent desc, s_order asc limit 0,{$_c['filtr']['step']}";
$r=mysql_query($d);
if (mysql_num_rows($r)>0) {
echo '<div class="cards">';
echo '<form method="POST">';
$i=0;
while ($row=mysql_fetch_array($r)):
echo '<div class="item">';
echo '<input id="'.$row['id'].'" type="radio" name="id" class="detail">'.$_l['detailtitle'].'</input>';
echo '<label for="'.$row['id'].'" class="itemin" style="height:'.$_c['card']['sy'].'px"><img src="pub/cards/'.$row['id'].'s.jpg" /></lable>';
echo '</div>';
$i++;
if ($i%3==0) echo '<div class="cl-left"></div>';
endwhile;
echo '<div class="cl-left"></div>';
echo '</div>';
}
?>
<div class="dvasl">
<div class="sl1">
<fieldset>
<legend>Saatja andmed</legend>
<table class="info">
<colgroup><col width="12%"><col></colgroup>
<tr>
<th>Nimi:</th>
<td><input type="text" name="item[from_name]" value="<?php echo $ap['set']['from_name']; ?>" class="inpedit"></td>
</tr>
<tr>
<th>Email:</th>
<td><input type="text" name="item[from_email]" value="<?php echo $ap['set']['from_email']; ?>" class="inpedit"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Saaja andmed</legend>
<table class="info">
<colgroup><col width="12%"><col></colgroup>
<tr>
<th>Nimi:</th>
<td><input type="text" name="item[to_name]" value="<?php echo $ap['set']['to_name']; ?>" class="inpedit"></td>
</tr>
<tr>
<th>Email:</th>
<td><input type="text" name="item[to_email]" value="<?php echo $ap['set']['to_email']; ?>" class="inpedit"></td>
</tr>
</table>
</fieldset>
</div>
<div class="sl2">
<fieldset>
<legend>E-kaardi tekst</legend>
<table class="info">
<tr>
<td><textarea name="item[text]" cols="20" rows="8" class="inpedit2"></textarea></td>
</tr>
</table>
</fieldset>
</div>
<div class="cl-left"></div>
</div>
<div class="buttons">
<div class="t2"><input type="submit" value="Vaata kaardi eelvaadet" name="button[nahled]" class="unbutt1"></div>
</div>
<input type="hidden" name="id" value="<?php echo $ap['card']['id']; ?>">
<input type="hidden" name="action" value="itemadd">
</form>
<?php
$k=floor(($i-1)/3);
if ($k<2) echo '<div class="spacer-'.(2-$k).'"></div>';
?>