我想知道是否有人能够帮助我。将单选按钮值传递给表单提交
我把放在一起的this页面允许用户查看保存在他们账户中的记录。
我现在要做的是添加用户可以选择一个单选按钮的功能,单击“位置详细信息”图标,然后将它们带到与“记录”相关的“详细信息页”已经选择了反对的单选按钮。
我遇到的问题是,无论选择哪个单选按钮,当我单击图标时,我都会被带到最后一条记录的“详细信息页面”。 (*NB *对于这个职位,我已经采取了“提交”行动远离按钮的用途。)
下面的代码创建表和“详细地点”图标
<table id="theTable" width="835" class="sortable-onload-zebra no-arrow rowstyle-alt colstyle-alt paginate-20 max-pages-20 paginationcallback-callbackTest-calculateTotalRating paginationcallback-callbackTest-displayTextInfo sortcompletecallback-callbackTest-calculateTotalRating">
<thead>
<tr>
<th width="60" bgcolor="#ff8401">Select</th>
<th width="150" class="sortable-text" bgcolor="#ff8401">Location</th>
<th width="300" class="sortable-text" bgcolor="#ff8401">Address</th>
<th width="30" class="sortable-text" bgcolor="#ff8401">Finds</th>
</tr>
</thead>
<tbody>
<?php
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result)) {
/* display row for each user */
?>
<tr height="80px">
<td style="text-align: center"><input type="radio" id="lid" name="lid" value=<?php echo $row['locationid'];?> /></td>
<td style="text-align: left"><strong><?php echo $row['locationname'];?></strong></td>
<td style="text-align: center"><?php echo $row['returnedaddress'];?></td>
<td style="text-align: center"><strong><em><?php echo $row['totalfinds'];?></em></strong></td>
</tr>
<?php
}
} else {
echo "<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan='5'><div align='center'><strong>No locations have been added yet. <a href='addlocation.php'>Click here</a> to add one.</strong></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>";
}
?>
<form action='locationsaction.php'>
<input type='submit' class='detailsButton' name='type' value='Details' alt='Location Details' title='Location Details' style='margin-right:10px' />
</form>
</tbody>
</table>
因为我打算在一个表单中有几个提交按钮,所以我创建了以下'locationsaction.php'脚本,您将在上面的脚本中调用您将看到的脚本。
<?php
session_start();
$_SESSION['lid'] = $_POST['lid'];
if (isset($_POST['type'])) {
$urls = array(
'Details' => 'locationdetails.php',
'Add Finds' => 'addfinds.php',
'Images' => 'addimages.php',
'View Finds' => 'locationfinds.php'
);
$url = $urls[$_POST['type']];
header("Location: " . $url);
}
?>
我一直在这工作了好几天,并尝试了几个教程,但我似乎无法得到这个工作。
我只是想知道是否有人能够看看这个请提供一些指导,我如何通过'提交行动传递正确的单选按钮值。
许多的感谢和亲切的问候
嗨@andrewsi,非常感谢您花时间回复我的帖子。一旦我发布了这篇文章,我偶然发现了另一个基本上证实了你的说法的教程。亲切的问候 – IRHM