0
這些值來自數據庫。我想從表中選擇一行,然後將這些值傳遞給名爲OInfo.php的下一個PHP頁面。我嘗試使用JavaScript並將這些值放入文本框中,但是當我點擊繼續按鈕時,即使使用請求方法也不會獲得這些值。我能做什麼?從PHP表中選擇值並將其傳遞給另一個PHP頁面
<form action="OInfo.php" METHOD="POST">
<div class="table-responsive">
<table class="table table-hover table-datatable table-striped table-bordered" id="tableresult">
<thead>
<tr>
<th><center>Sección</center></th>
<th><center>Espacios Disponibles</center></th>
<th><center>Tiempo de espera</center></th>
<th><center>Opciones</center></th>
</tr>
</thead>
<!---Start of code--->
<tbody>
<?php
$query="SELECT * FROM department where dept_id='$id'";
$result1 = mysql_query($query);
$row1 = mysql_fetch_array($result1);
$list = explode(",", str_replace("'", "", substr($row1['dept_schedule'], 0, (strlen($row1['dept_schedule'])+0))));
foreach($list as $value){
echo "<tr>";
echo "<td><center>$value</center></td>";
echo "<td><center>20</center></td>";
echo '<td><center><input type="radio" name="select" value="select"> Seleccionar</center></td>';
echo "</tr>";
}
?>
<input type='text' name="schedule" id="schedule" value="<? php $value ?>">
</tbody>
<!---End of code--->
</table>
</div>
<div class='inputWrapper'>
<input type='text' name="schedule" id="schedule" >
</div>
</div>
</form>
<?php
echo '<a href="OInfo.php?id='.$data['dept_id'].'"><input type="submit" value="Continuar" class="btn btn-primary" style="float:right;"></a>';
?>
這是JavaScript代碼:
<script>
$('#tableresult tr').click(function(event) {
$('td', this).each(function(i) {
$('.inputWrapper input').eq(i).val(this.textContent);
});
});
</script>
你嘗試AJAX? – Manikiran
無關緊要,但看看mysqli/PDO,而不是mysql_ - 讓這種生活將是不安全的。 –
您的提交按鈕回聲應該位於表單標記內。爲什麼它在<標籤內?還有,爲什麼你通過Url傳遞變量? – VipindasKS