javascript - 如何提交 php 表单和弹出 javascript 的值?
问题描述
我创建了一个 PHP 页面,其中包含一些表单信息,并且在表单末尾我有一个提交按钮。我知道如何使用 PHP post 方法从表单中获取所有用户输入。我的问题如下,如何创建一个在用户单击提交按钮后弹出的迷你弹出表单。弹出表单会询问用户提交信息是否紧急,用户只需在紧急或不紧急之间进行选择,然后单击迷你弹出表单中的按钮(“继续”)即可关闭弹出窗口up 并将用户输入的所有信息与弹出窗口一起发送到不同的 PHP 页面。有人可以指导这个问题吗?
我目前表格的源代码如下
<?php include "includes/tasksheader.php"; ?>
<link href="https://fonts.googleapis.com/css?family=Oleo+Script:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Teko:400,700" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<div class="main1">
<div class="contact-section">
<div class="container">
<form>
<div class="col-md-6 form-line">
<div class="form-group">
<label for="exampleInputUsername">Social Ensuarance Number</label>
<input type="text" class="form-control" id="" placeholder="Ensuarance Number">
</div>
<div class="form-group">
<label for="exampleInputEmail">Land Regisrty Department</label>
<input type="email" class="form-control" id="exampleInputEmail" placeholder="Land Registry">
</div>
<div class="form-group">
<label for="telephone">Income Tax Office</label>
<input type="tel" class="form-control" id="telephone" placeholder="Tax Office">
</div>
<div class="form-group">
<label for="telephone">Court</label>
<input type="tel" class="form-control" id="telephone" placeholder="Court">
</div>
<div class="form-group">
<label for="telephone">Limassol District Administration</label>
<input type="tel" class="form-control" id="telephone" placeholder="District Administration">
</div>
<div class="form-group">
<label for="telephone">Municipality</label>
<input type="tel" class="form-control" id="telephone" placeholder="Municipality">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputUsername">VAT Department</label>
<input type="text" class="form-control" id="" placeholder="VAT">
</div>
<div class="form-group">
<label for="exampleInputEmail">RCB Bank</label>
<input type="email" class="form-control" id="exampleInputEmail" placeholder="RCB Bank">
</div>
<div class="form-group">
<label for="telephone">Hellenic Bank</label>
<input type="tel" class="form-control" id="telephone" placeholder="Hellenic Bank">
</div>
<div class="form-group">
<label for="telephone">Bank of Cyprus</label>
<input type="tel" class="form-control" id="telephone" placeholder="Bank of Cyprus">
</div>
<div class="form-group">
<label for="telephone">CDB Bank</label>
<input type="tel" class="form-control" id="telephone" placeholder="CDB Bank">
</div>
<div class="form-group">
<label for="telephone">Other</label>
<input type="tel" class="form-control" id="telephone" placeholder="Other">
</div>
</div>
<div class="form-group">
<label for ="description"> Message</label>
<textarea class="form-control" id="description" placeholder="Enter Your Message"></textarea>
<div>
<button type="button" class="btn btn-default submit"><i class="fa fa-paper-plane" aria-hidden="true"></i> Send Message</button>
</div>
</div>
</form>
</div>
</div>
</div>
致谢
解决方案
我猜你需要做以下事情:首先创建弹出表单(有两个按钮......)然后你需要在你的 javascript 文件中编写以下内容:
$('form').on("submit", function(e){
e.preventDefault();
$('popup').fadeIn();
...
}
或者
$('button').on("click", function(e){
e.preventDefault();
$('popup').fadeIn();
...
}
然后在您的弹出窗口中,您将再次需要preventDefault
并按照您的意图做任何事情。我希望它有帮助:)
推荐阅读
- c# - NJsonSchema - C# 代码生成器不输出命名空间
- c++ - 删除字符串中嵌入的空字符
- asp.net-mvc - ASP.NET MVC 分页列表松散复选框列表过滤器
- python - 使用在线 LDA 预测测试数据
- google-maps - 在 PF 对话框中将命名 Bean 变量作为 Primefaces gmap 函数的参数传递
- javascript - Chart.js 不工作 - 未捕获的 ReferenceError:
- angularjs - AngularJS注销不适用于匿名函数
- git - 当我们从 Azure DevOps 拉取源代码时,与 Sync 的不同拉取
- python - 不正确的模式计算还是这是盐和胡椒?
- android - 如何基于 JSON 对象构建 ListView 并在 onItemClick 之后传递其数据