[英]Bootstrap Modal Form Submit
我已经使用HTML,Bootstrap CSS和PHP实现了一个有效的Modal表单,该表单显示了有关文档的信息。 在模式的页脚中,我有一个“删除文档”按钮,该按钮应该发布到同一页面(index.php)。 表单不响应“提交”按钮。
阅读此主题的很多人正在使用AJAX从Bootstrap Modal提交。 这似乎不必要吗? 我是否真的需要在AJAX中实现JSON帖子才能提交此模式?
编码:
<div class="modal-footer">
<form action="index.php" method="post">
<input type="hidden" name="DocumentID" value="<?php echo $row['DocumentID']; ?>" />
<input type="hidden" name="top-search" value="<?php echo $_POST['top-search']; ?>" />
<button type="submit" name="deleteDocument" class="btn btn-w-m btn-danger" onclick="return confirm('Are you sure you want to delete this Document?')">Delete</button>
</form>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
我有一个示例,尽管使用类似的方法但使用target =“ _ blank”,模态成功提交到其他页面,
它不是onclick-而是onClick。
另外,您需要将脚本放在{}中。 下面的代码应该工作。
/*
* A simple React component
*/
class Application extends React.Component {
render() {
return (<div class="modal-footer">
<form action="index.php" method="post">
<input type="hidden" name="DocumentID" value="<?php echo $row['DocumentID']; ?>" />
<input type="hidden" name="top-search" value="<?php echo $_POST['top-search']; ?>" />
<button type="submit" name="deleteDocument" class="btn btn-w-m btn-danger" onClick={ function() {
return confirm("Yes/No?");
}}>Delete</button>
</form>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>);
}
}
/*
* Render the above component into the div#app
*/
React.render(<Application />, document.getElementById('app'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.