存储表单数据并使用HTML5 LocalStorge在另一页上打印

时间:2017-07-20 13:21:57

标签: javascript html html5

我有这个联系表格:

HTML代码:

<form class="form-horizontal" id="contact-form" action="thanks.html" method="post">
    <fieldset>
        <div class="text-center header"><h1>צור קשר</h1></div>
        <div class="form-group">
            <div class="col-md-10 col-md-offset-1">
                <input id="fname" name="name" type="text" placeholder="שם פרטי ושם משפחה  (חובה)" class="form-control" tabindex="1" required autofocus>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-10 col-md-offset-1">
                <input id="email" name="email" type="email" placeholder="מייל: example@hotmail.com (חובה)" class="form-control" tabindex="2" required autofocus>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-1">
                <input id="phone" name="phone" type="tel" placeholder="טלפון (חובה)" class="form-control" tabindex="3" required>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-1">
                <textarea class="form-control" id="message" name="message" placeholder="הכנס את הודעתך לנו כאן:" rows="7" tabindex="4" required></textarea>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-12 text-center">


<button name="submit" type="submit" class="btn btn-primary btn-lg" id="contact-submit">Send Email</button>

        </div>
    </div>
</fieldset>

JavaScipt代码:

(function() {

// Create input element for testing
var inputs = document.createElement('input');

// Create the supports object
var supports = {};

supports.autofocus   = 'autofocus' in inputs;
supports.required    = 'required' in inputs;
supports.placeholder = 'placeholder' in inputs;

// Fallback for autofocus attribute
if(!supports.autofocus) {

}

// Fallback for required attribute
if(!supports.required) {

}

// Fallback for placeholder attribute
if(!supports.placeholder) {

}

// Change text inside send button on submit
var send = document.getElementById('contact-submit');
if(send) {
    send.onclick = function () {
        this.innerHTML = '...Sending';
    }
}

})();

所以我想打印用户在thanks.html页面上的表单上输入的名称和电子邮件

赞:谢谢“用户名”我们会尽快回复您。 您的电子邮件地址是:useremail here

0 个答案:

没有答案