确定表单确认方法 [英] Deciding between form confirmation methods

查看:131
本文介绍了确定表单确认方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我最初想创建一个表单,该表单在成功提交表单数据时会生成一个灯箱,表示感谢您提交表单,但我读到,仅将用户带到谢谢"页面是该表单最安全和最保证的方式要通知用户的是先前所述的经典方法.如果使用花哨的盒子证明有效,那么我将如何做呢? javascript的调用会去哪儿?在PHP或HTML文件中,表单处于打开状态吗?由于该页面仅适用于移动设备和平板电脑,而且非常简单,因此我认为使用灯箱(我要添加fancybox)是一个好主意,而不是制作更多页面.

So I originally wanted to create a form that generated a lightbox ON successful submission of the form data saying thanks for submitting the form but I read that just taking the user to a thank you page was the safest and most assuring way for the user to be notified is with that classic method stated earlier. IF using the fancy box proves effective how exactly would I go about doing this? Where would the call for the javascript go? In the PHP or the HTML file the form is on? Since the page is mobile and tablet only and so simple I thought it would be a good idea to use the lightbox (I'm looking at adding fancybox) instead of making more pages.

我也很难在网上找到资源,因为我只是得到灯箱形式,并以抽签形式将提交结果发送回去.我只想要一个简单的谢谢"或错误"消息.那就是说,这对于表单来说是一个很好的可行解决方案.

I'm having trouble finding resources on the net as well, as I'm just getting lightbox forms and sending submission results back in the form of a lot box. I just want a simple Thank You or Error message honestly. That is if this is a good workable solution for a form at all.

提前谢谢!

这是裁判的基本形式.

<form id="fusion_form" name="fusion_form" method="post" action="fusion_form.php" target="_blank">
                        <p><input name="first_name" type="text" id="first_name" style="width:140px" value="" placeholder="First Name" /></p>
                        <p><input name="last_name" type="text" id="last_name" style="width:140px"  value="" placeholder="Last Name" /></p>
                        <p><input name="email" type="text" id="email" style="width:140px"  value="" placeholder="Email Address" /></p>
                        <p><textarea name="comments" cols="20" rows="3" id="comments" class="FormText" style="width:200px; padding-left:2px" placeholder="Comments"></textarea></p>
                        <p><input type="image" src="images/submit-button.jpg" id="send_email" value="Submit Form" onclick="return verify_form();" /></p>
</form>

推荐答案

$('form').on('submit', function(e){
    e.preventDefault(); // stop the form submission
    var $d = $(this).serialize(); //serialize form to be submit to server
    $.ajax({
        url: $(this).prop('action'),
        type: $(this).prop('method'),
        data: {formData : $d},
        success: function(data){
            if(false != data){
               //form submission did NOT return false
               //build lightbox, extrapolate what is needed from `data` variable
            }
        }
    });
});

php.

if(isset($_POST['formData'])):
    $formData = $_POST['formData]';
    //do whatever with the form
    if(someCondition):
       return '<h4> Thank you for submitting the form!</h4>';
    else:
       return false;
    endif;
endif;

这篇关于确定表单确认方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆