2017-02-25 85 views
1

我想添加一個微調框的提交按鈕,當表單正在提交過程中。微調提交表單時提交表格

表單提交正常,但我無法讓微調顯示。 請幫幫我。

(function() { 
 
    $(document).on("click", "#submitbutton", function (event) { 
 
     var elem = $(event.currentTarget); 
 
     elem.addClass('active'); 
 
     var formdata = $("#filterdata").serializeArray(); 
 
     var url1 = "/SelectUnit"; 
 
     $.ajax({url:"/echo/html", data: {delay:1}}).always(function(){ 
 
      elem.removeClass('active'); 
 
     }); 
 
    }); 
 
})();
.spinner { 
 
    opacity: 0; 
 
    display:none; 
 
    width: 20px; 
 
    height:10px; 
 
    -webkit-transition: opacity 0.25s, max-width 0.45s; 
 
    -moz-transition: opacity 0.25s, max-width 0.45s; 
 
    -o-transition: opacity 0.25s, max-width 0.45s; 
 
    transition: opacity 0.25s, max-width 0.45s; 
 
    /* Duration fixed since we animate additional hidden width */ 
 
} 
 
.has-spinner.active { 
 
    cursor:progress; 
 
} 
 
.has-spinner.active .spinner { 
 
    display:inline-block; 
 
    opacity: 1; 
 
    max-width: 50px; 
 
    /* More than it will ever come, notice that this affects on animation duration */ 
 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/todc-bootstrap/3.3.6-3.3.6/js/bootstrap.min.js"></script> 
 

 
<form id="quote-form" method="post" action="quote.php"> 
 
          
 
<div class="col-md-12"> 
 
<div class="messages"></div> 
 
</div> 
 

 
<div class="col-sm-6"> 
 
<div class="form-group"> 
 
<input id="form_subject" type="text" name="subject" class="form-control" placeholder="Subject *" required="required" data-error="Subject is required."> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
</div> 
 

 
<div class="col-sm-6"> 
 
<div class="form-group"> 
 
<input id="form_name" type="text" name="name" class="form-control" placeholder="Your Name *" required="required" data-error="Your Name is required."> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
</div> 
 

 
<div class="col-sm-6"> 
 
<div class="form-group"> 
 
<input id="form_phone" type="tel" name="phone" class="form-control" placeholder="Please enter your phone"> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
</div> 
 

 
<div class="col-sm-6"> 
 
<div class="form-group"> 
 
<input id="form_email" type="email" name="email" class="form-control" placeholder="Please enter your email *" required="required" data-error="Valid email is required."> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
</div> 
 

 
<div class="col-sm-6"> 
 
<select id="form_contact_method" name="contact_method" class="selectpicker"> 
 
\t <option selected>Prefered contact method?</option> 
 
\t <option value="Phone">Phone</option> 
 
\t <option value="Email">Email</option> 
 
</select> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
          
 
<div class="col-sm-6"> 
 
<select id="form_budget" name="budget" class="selectpicker"> 
 
    <option selected>Approximate budget?</option> 
 
    <option class="custom-select-option" value="&euro; 50,- to &euro; 100,-">&euro; 50,- to &euro; 100,-</option> 
 
    <option class="custom-select-option" value="&euro; 100,- to &euro; 250,-">&euro; 100,- to &euro; 250,-</option> 
 
    <option class="custom-select-option" value="&euro; 250,- to &euro; 500,-">&euro; 250,- to &euro; 500,-</option> 
 
    <option class="custom-select-option" value="&euro; 500,- to &euro; 1000,-">&euro; 500,- to &euro; 1000,-</option> 
 
    <option class="custom-select-option" value="&euro; 1000,- plus">&euro; 1000,- plus</option> 
 
</select> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 

 
<div class="col-sm-12 "> 
 
<div class="form-group"> 
 
<textarea id="form_message" name="message" class="form-control textarea" placeholder="Tell Us About Your Project" rows="5" required="required" data-error="Please,leave us a message."></textarea> 
 
<div class="help-block with-errors"></div> 
 
</div> 
 
</div> 
 

 
<div class="formbuttons"> 
 
<button type="submit" id="submitbutton" class="btn buttoncolor has-spinner"> <span class="spinner"><img src="http://assets2.bostonlogic.com/images/spinner.gif" width="10" height="10"></span>Get a Quote</button> 
 
</div> 
 

 
</form>

我曾用jQuery試圖提交和許多其他片斷我喜歡到目前爲止沒有成功。

回答

0

您是否嘗試在您的html文件中包含jQuery庫?

+0

是的,這包括 – user2765741

0

我在這裏創建了一個jsfiddle鏈接,您的微調工作在該提交按鈕上,您可以檢查該按鈕。

https://jsfiddle.net/shamshi1988/crmu4jav/

+0

謝謝您的回答我還在努力使其工作,我覺得有可能是在我的網頁一些風格從工作我會繼續努力,讓你停止它已更新 – user2765741

+0

我一直在努力嘗試着沒有成功 – user2765741

+0

你可以告訴我你面臨什麼問題。我已經給出了鏈接,你可以看到它的工作.... – Shamshi786