我已经从自由职业者引导程序模板修改了表单'我添加了几个复选框。问题是,当我提交表单时,我没有从我的电子邮件中的复选框中获取值(其余的都没问题)。
以下是代码行:
HTML:
<form></form>
JS
<div class="row control-group">
<label id="areas">Areas of Interest:</label>
<label class="checkbox"><input type="checkbox" name="areasofinterest[]" value="trade_show_events">trade show & events</label>
<label class="checkbox"><input type="checkbox" name="areasofinterest[]" value="websites_optimiaztion">websites & optimization</label>
<label class="checkbox"><input type="checkbox" name="areasofinterest[]" value="online_promotions">online promotions</label>
<label class="checkbox"><input type="checkbox" name="areasofinterest[]" value="strategic_planning_branding">strategic planning & branding</label>
</div>
PHP
$(function() {
$("#contactForm input,#contactForm textarea").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {
// additional error messages or events
},
submitSuccess: function($form, event) {
// Prevent spam click and default submit behaviour
$("#btnSubmit").attr("disabled", true);
event.preventDefault();
// get values from FORM
var name = $("input#name").val();
var companyname = $("input#companyname").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
var areasofinterest = $("input#areasofinterest").val();
var message = $("textarea#message").val();
var firstName = name; // For Success/Failure Message
// Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = name.split(' ').slice(0, -1).join(' ');
}
$.ajax({
url: "././mail/contact_me.php",
type: "POST",
data: {
name: name,
companyname: companyname,
phone: phone,
email: email,
areasofinterest: areasofinterest,
message: message
},
我真的很感谢你的帮助:)。
提前致谢!