如何在显示为表行的自动生成的表单中获取输入值(复选框输入)?

时间:2016-04-14 03:26:14

标签: javascript php jquery checkbox sql-update

我从数据库生成表,将每个单元格指定为复选框值,将每一行分组为表格并将它们全部显示为表格参考[this]。1当我点击时,我如何获得特定的单元格值按钮,因为每个表单(行)具有相同的ID。我想传递值作为查询参数来更新数据库表。我搜索了类似的技术,仍然没有找到解决方案。

此代码位于游标提取循环中:

				<form class="tr" id="barisn" method="post" action="">
					<span class="td"><input type="checkbox" name="id" value="<?php $data[0]?>"/><label for="id"><?php echo $data[0]?></label></span>
					<span class="td"><input type="checkbox" name="name" value="<?php $data[1]?>" /><label for="name"><?php echo $data[1]?></label></span>
					<span class="td"><input type="checkbox" name="gender" value="<?php $gender?>" /><label for="gender"><?php echo $gender?></label></span>
					<span class="td"><input type="checkbox" name="sender" value="<?php $data[8]?>" /><label for="sender"><?php echo $data[8]?></label></span>
					<span class="td"><input type="checkbox" name="date" value="<?php $data[5]?>" /><label for="date"><?php echo $data[5]?></label></span>
					<span class="td"><input type="checkbox" name="time" value="<?php $data[6]?>" /><label for="time"><?php echo $data[6]?></label></span>
					<span class="td"><input type="checkbox" name="state" value="<?php $state?>" /><label for="state"><?php echo $state?></label></span>
					<div class="td">
						<button class="btn-rawuh" type="submit" form="barisn" value="Rawuh">Rawuh</button>
						<button class="btn-tundha" type="submit" form="barisn" value="Tundha">Tundha</button>
						<button class="btn-mlebet" type="submit" form="barisn" value="Mlebet">Mlebet</button>
					</div>
				</form>

The point is I still can not find a method to indexing row as user may click a button in it. Table result:

1 个答案:

答案 0 :(得分:0)

你必须把锚标记而不是像这样的按钮

<a href="edit.php?id=<?php echo $here_ur_dynamic_PK_of_that_row[index_value] ?>">Edit</a>

当你点击编辑按钮然后页面将重定向到edit.php(你必须创建新的php文件)然后从url获取id:

echo $_GET method

然后你将使用id(使用查询)获取该特定行的详细信息。