Ist es möglich, die mailto:
-Funktion wie die <input type="submit" />
-Schaltfläche beim Senden zu implementieren? Ich verwende ASP.NET MVC. Möglicherweise gibt es einige knifflige Controller-Aktionsergebnisse, um dies zu erreichen. Kannst du mir bitte Helfen?
P.S. Ich weiß, dass ich Anker-Looks wie einen Knopf machen kann.
In HTML können Sie eine mailto:
-Adresse im <form>
-Attribut des [action]
-Elements angeben.
<form action="mailto:[email protected]" method="GET">
<input name="subject" type="text" />
<textarea name="body"></textarea>
<input type="submit" value="Send" />
</form>
Dies ermöglicht es dem E-Mail-Client des Benutzers, eine E-Mail zu erstellen, die mit den Feldern im <form>
ausgefüllt ist.
Was dieses nicht tut, ist eine E-Mail zu senden.
Das scheint gut zu funktionieren:
<button onclick="location.href='mailto:[email protected]';">send mail</button>
Sie müssen das onchange -Ereignis im Formular verwenden. Ändern Sie das href-Attribut der Schaltfläche "Senden" entsprechend dem Kontext der E-Mail.
<form id="form" onchange="mail(this)">
<label>Name</label>
<div class="row margin-bottom-20">
<div class="col-md-6 col-md-offset-0">
<input class="form-control" name="name" type="text">
</div>
</div>
<label>Email <span class="color-red">*</span></label>
<div class="row margin-bottom-20">
<div class="col-md-6 col-md-offset-0">
<input class="form-control" name="email" type="text">
</div>
</div>
<label>Date of visit/departure </label>
<div class="row margin-bottom-20">
<div class="col-md-3 col-md-offset-0">
<input class="form-control w8em" name="adate" type="text">
<script>
datePickerController.createDatePicker({
// Associate the text input to a DD/MM/YYYY date format
formElements:{"adate":"%d/%m/%Y"}
});
</script>
</div>
<div class="col-md-3 col-md-offset-0">
<input class="form-control" name="ddate" type="date">
</div>
</div>
<label>No. of people travelling with</label>
<div class="row margin-bottom-20">
<div class="col-md-3 col-md-offset-0">
<input class="form-control" placeholder="Adults" min=1 name="adult" type="number">
</div>
<div class="col-md-3 col-md-offset-0">
<input class="form-control" placeholder="Children" min=0 name="childeren" type="number">
</div>
</div>
<label>Cities you want to visit</label><br/>
<div class="checkbox-inline">
<label><input type="checkbox" name="city" value="Cassablanca">Cassablanca</label>
</div>
<div class="checkbox-inline">
<label><input type="checkbox" name="city" value="Fez">Fez</label>
</div>
<div class="checkbox-inline">
<label><input type="checkbox" name="city" value="Tangier" >Tangier</label>
</div>
<div class="checkbox-inline">
<label><input type="checkbox" name="city" value="Marrakech" >Marrakech</label>
</div>
<div class="checkbox-inline">
<label><input type="checkbox" name="city" value="Rabat" >Rabat</label>
</div>
<div class="row margin-bottom-20">
<div class="col-md-8 col-md-offset-0">
<textarea rows="4" placeholder="Activities Intersted in" name="activities" class="form-control"></textarea>
</div>
</div>
<div class="row margin-bottom-20">
<div class="col-md-8 col-md-offset-0">
<textarea rows="6" class="form-control" name="comment" placeholder="Comment"></textarea>
</div>
</div>
<p><a id="send" class="btn btn-primary">Create Message</a></p>
</form>
funktionsmail (Formular) {
var name=form.name.value;
var city="";
var adate=form.adate.value;
var ddate=form.ddate.value;
var activities=form.activities.value;
var adult=form.adult.value;
var child=form.childeren.value;
var comment=form.comment.value;
var warning=""
for(i=0;i<form.city.length;i++)
{
if(form.city[i].checked)
city+=" "+form.city[i].value;
}
var str="mailto:[email protected]?subject=travel to morocco&body=";
if(name.length>0){
str+="Hi my name is "+name+", ";
}else{
warning+="Name is required"
}
if(city.length>0){
str+="I am Intersted in visiting the following citis: "+city+", ";
}
if(activities.length>0){
str+="I am Intersted in following activities: "+activities+". "
}
if(adate.length>0){
str+="I will be ariving on "+adate;
}
if(ddate.length>0){
str+=" And departing on "+ddate;
}
if(adult.length>0){
if(adult==1&&child==null){
str+=". I will be travelling alone"
}else if(adult>1){
str+=".We will have a group of "+adult+" adults ";
}
if(child==null){
str+=".";
}else if(child>1){
str+="along with "+child+" children.";
}else if(child==1){
str+="along with a child.";
}
}
if(comment.length>0){
str+="%0D%0A"+comment+"."
}
if(warning.length>0){
alert(warning)
}
else{
str+="%0D%0ARegards,%0D%0A"+name;
document.getElementById('send').href=str;
}
}
Die vollständige Liste der möglichen Felder im HTML-basierten E-Mail-Erstellungsformular:
<form action="mailto:[email protected]" method="GET">
<input name="subject" type="text" /></br>
<input name="cc" type="email" /><br />
<input name="bcc" type="email" /><br />
<textarea name="body"></textarea><br />
<input type="submit" value="Send" />
</form>
Oder Sie erstellen ein Formular mit Aktion: mailto
<form action="mailto:[email protected]">
schau dir das an.
http://webdesign.about.com/od/forms/a/aa072699mailto.htm
Dies sendet jedoch tatsächlich ein Formular per E-Mail. Ist es das, was Sie wollten? Sie können es auch einfach verwenden
<button onclick="">
und dann etwas Javascript mit, um dies zu glauben.
Und Sie können einen <a>
-Button wie Button ..__ machen. Es gibt viele Möglichkeiten, dies zu umgehen. Mach eine kleine Suche.
Fügen Sie einfach "ein" Tag im "Button" -Tag ein.
<button><a href="mailto:..."></a></button>