javascript - 在 PHP 中从网格中获取 id
问题描述
我正在使用 PHP 进行后端开发。
我在 Html 中有网格,其中包含一堆记录。
现在我想要的是,我想在点击时获得预订 ID(点击事件有
java脚本函数)在预订
具有超链接的数字(如下图所示。)。
This is the java script function to get booking id on click of booking Number
$('.bu').on('click', function () {
var Id = $(this).data("id");
$.get( "mypage.php?id=" + Id );
document.getElementById("idvalue").value = Id;
var inputdaata=document.getElementById("idvalue").value;
**From above javascript already getting Booking id.
Now i have to use that booking id in php.
This is for grid in Html**
<td><a href="" name="abc"
class ="bu" data-toggle="modal"
data-target="#myModal1"
data-id="<?php echo $json1[$i]
['bookingid']; ?>"><?php echo
$json1[$i]['bookingNumber'];?>
</a></td>
提前致谢。
解决方案
<script type="text/javascript">
function gocedula(text) {
var form_data = {
is_ajax: 1,
cedula: text
};
$.ajax({
type: "POST",
url: "getCedula.php",
data: form_data,
success: function(response) {
window.location.replace("http://stackoverflow.com");
}
});
}
</script>
<a onclick="gocedula('.$valor.')">Booking Number</a>
在其他页面上使用
$_REQUEST["cedula"];
推荐阅读
- android - kotlin Android 中以编程方式生成的视图的数据绑定
- bash - 在bash中使用通配符复制多个文件
- jenkins-pipeline - 在 Jenkins 管道中,如何将字符串转换为日期?
- json - 从 JSON 字符串中提取全名
- visual-studio - Visual Studio 中的 CMake 未正确设置 CMAKE_BINARY_DIR
- flutter - 如何在地图中的两个标记之间进行缩放
- html - Angular - View 打印旧值和新值
- python - 对于字典,将键和值都与列表中的值进行比较
- css - 如何更改子菜单项颜色
- reactjs - 反应路由器访问控制