简体   繁体   English

在Bootstrap模式中显示表单结果

[英]Display Form Results in Bootstrap Modal

I have included a simple form on the home page of our website that posts its results to a page named Results.aspx. 我在我们网站的主页上包含了一个简单的表单,该表单将其结果发布到名为Results.aspx的页面上。

Instead of the form's results returning on the same page, I'd like it if the results opened in a new modal. 如果结果以新模式打开,而不是表单的结果在同一页面上返回,则不希望这样做。

How is this accomplished? 这是如何完成的? To recap, the form is on the home page, and on submit, the results should be shown in a new modal window. 回顾一下,表单在主页上,提交后,结果应显示在新的模式窗口中。

<form action="Results.aspx" method="post" name="myForm" onsubmit="return validateForm()">
<div id="blank-box-form">
<h2>Looking For Medicare Advantage Plans?</h2>
<label for="zipcode1"> Please enter your zip code</label>
<input id="zipcode1" class="wpcf7" name="zipcode1" type="text" />


<input type="submit" />

</div>

I would suggest that you post the form using ajax. 我建议您使用ajax发布表单。 When the ajax-call is complete you populate the body of the modal with the response-data and open it up :) 完成ajax调用后,您将使用响应数据填充模态的主体并打开它:)

Try 尝试

<form action="Results.aspx" target="_blank" method="post" name="myForm" onsubmit="return validateForm()">

But ass @digi recommend, you should use ajax to get the results and then insert them in a modal. 但是ass @digi建议,您应该使用ajax来获取结果,然后将其插入模式中。

This could guide you: 这可以指导您:

<script>
    $("form").submit(function(event){
        event.preventDefault();//to stop the submit
        $.get("url","data",function(results){
            $("#someModalStyledDiv").html(results).show();
        });
    });
</script>

http://api.jquery.com/jquery.get/ http://api.jquery.com/jquery.get/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM