我希望将传递ID值传递给POPUP DIV并更新到包含status的suggest_text区域的表中。
如果我像这样传递href="#pop1?id=<?php echo $row['id']; ?>
POPUP div未打开。所以我不知道如何通过,所以有人告诉我如何通过PHP或其他Javascript传递
提前致谢
<div class="widget-content">
<table class="table table-bordered table-striped data-table">
<thead>
<tr>
<th>S.No</th>
<th>Employee Name</th>
<th>Reason</th>
<th>Category</th>
<th>From</th>
<th>To</th>
<th>No Of Days</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$result=mysql_query("select * from leave_request");
while($row=mysql_fetch_array($result))
{?>
<tr>
<td><?php echo $row['id'];?></td>
<td> <?php echo $row['emp_name'];?></td>
<td> <?php echo $row['reason'];?></td>
<td> <?php echo $row['category'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['no_of_days'];?></td>
<td>
<a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='1'" style="text-decoration:none;">Accept </a> |
<a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='2'"> Reject </a>|
<a href="#pop1?id=<?php echo $row['id']; ?>"> Suggest</a> </td>
<div id="pop1" class="pop-up">
<?php $suggest_id = $_GET['id']; ?>
<div class="popBox">
<div class="popScroll">
<form>
<textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
<input type="text" name="id" value="<?php echo $suggest_id; ?>">
<input type="text" name="status" value="3">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
<!-- popup content end here -->
</div>
<a href="#links" class="close"><span>Back to links</span></a>
</div>
<a href="#links" class="lightbox">Back to links</a>
</div>
</tr>
<?php }?>
</tbody>
</table>
</div>
答案 0 :(得分:0)
我看到你的popup div在WHILE循环中,所以你可以得到你的id: -
初始化一个值K = 1;
并将此值放入每个弹出窗口
<a href="#pop<?php echo $k; ?>"> Suggest</a>
完整代码: -
<?php
$result=mysql_query("select * from leave_request");
while($row=mysql_fetch_array($result))
{
$k =1;
?>
<tr>
<td><?php echo $row['id'];?></td>
<td> <?php echo $row['emp_name'];?></td>
<td> <?php echo $row['reason'];?></td>
<td> <?php echo $row['category'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['no_of_days'];?></td>
<td>
<a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='1'" style="text-decoration:none;">Accept </a> |
<a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='2'"> Reject </a>|
<a href="#pop<?php echo $k; ?>"> Suggest</a> </td>
<div id="pop<?php echo $k; ?>" class="pop-up">
<div class="popBox">
<div class="popScroll">
<form>
<textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
<input type="text" name="id" value="<?php echo $row['id']">
<input type="text" name="status" value="3">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
<!-- popup content end here -->
</div>
<a href="#links" class="close"><span>Back to links</span></a>
</div>
<a href="#links" class="lightbox">Back to links</a>
</div>
</tr>
<?php
$k++;
}?>