I need help with my contact formular on http://robert-richter.com under the navigation point Kontakt. I want to send this form with different subjects. Dependung on with option is selected in the drop down menu, I want to create an individual subject. The reason why I want to do this is because I want to use a filter in my email account wich saves emails based on the sibject title.
Example:
Contact Form Name: John Alex Option Selected: Anfrage persönlich // german for private request
Subject in Mailbox: Persönliche Anfrage von Alex John 23/08/2013
Filter 'Persönliche Anfrage von' and save it in the folder 'Persönliche Anfragen' (eng: Private Requests)
Im brand new to jQuery. This is what I got so far:
<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;
});
How can I add the selected option instead of the select element?