【发布时间】:2017-03-19 02:15:47
【问题描述】:
我的表中有一个按钮,原来是使用 GET 将一些变量发送到新页面 user.php ,但我不想在 url 中显示这些信息。 我尝试构建一个表单并将其提交给另一个 user.php,但 user.php 什么也没得到:
$('table').on( 'click', 'td .btn-info', function () {
var parent = $(this).closest('table').parents('tr').prev();
var parentIndex = parent.find('.index').text();
var currentIndex = $(this).closest('tr').index();
var data = sections[parentIndex][currentIndex];
var mapForm = document.createElement("form");
mapForm.target = "Map";
mapForm.method = "POST"; // or "post" if appropriate
mapForm.action = "user.php";
var name= document.createElement("input");
name.type = "hidden";
name.id = "name";
name.value = data.name;
mapForm.appendChild(name);
var loc= document.createElement("input");
loc.type = "hidden";
loc.id = "loc";
loc.value = data.loc;
mapForm.appendChild(loc);
document.body.appendChild(mapForm );
map=window.open("", "Map", "height=500,width=800,scrollbars=yes, resizable=yes");
if (map) {
mapForm.submit();
} else {
alert('You must allow popups for this map to work.');
}
} );
【问题讨论】:
标签: javascript button click window.open