我需要的導航點KONTAKT下我的聯繫公式推上http://robert-richter.com幫助。我想發送這個表格與不同的主題。在下拉菜單中選擇Dependung on with option,我想創建一個單獨的主題。我想這樣做的原因是因爲我想在我的電子郵件帳戶中使用過濾器,以保存基於sibject標題的電子郵件。如何發送形式的內容與不同的主題
例子:
聯繫表姓名:John亞歷克斯選擇選項:Anfragepersönlich//德國私人請求
主題的郵箱:PersönlicheAnfrage·馮·亞歷克斯·約翰23/08/2013
過濾器'PersönlicheAnfrage馮',並將其保存在文件夾 'PersönlicheAnfragen'(ENG:私人請求)在
林全新的jQuery的。這是我到目前爲止:
<form action="#" method="post" title="Kontaktformular" class="ajax">
<div><label for="name">Name</label>
<input name="name" type="text" title="Name"></div>
<div><label for="email">E-Mail-Adresse</label>
<input name="email" type="text" title="Email"></div>
<div><label for="auswahl">Präfix</label>
<label class="label">
<select name="auswahl" class="dropdown">
<option selected value="Webdesign">Anfrage Webdesign</option>
<option value="Persoenlich">Anfrage persönlich</option>
<option value="Andere">Alles andere</option>
<option value="Spam">Spam</option>
</select>
</label></div>
<div><textarea name="message" title="Nachricht"></textarea></div>
<button value="Send" type="submit" class="button">Absenden</button>
</form>
//php file
<?php
if (isset($_POST['name'], $_POST['email'],$_POST['auswahl'], $_POST['message'])) {
print_r($_POST);
}
$('form.ajax').on('submit', function() {
var that = $(this),
url = that.attr('action'),
type = that.attr('method'),
data = {};
that.find('[name]').each(function(index, value) {
var that = $(this),
name = that.attr('name'),
value = that.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
success: function(response) {
console.log(response);
}
});
return false;
});
如何添加所選擇的選項,而不是選擇元素?
你'that.find ...'語句包含一個函數,誰擁有一個名爲參數'value'。在該函數內部,您聲明一個具有相同名稱的局部變量。雖然這與你的問題沒有直接關係,但我想我會指出,因爲它聞起來很麻煩。 – UweB
更新http://jsfiddle.net/c5C8F/2/ –