Search code examples
javascriptformsselectionmailto

Open mail on selection change


I want to generate a specific mailto by choosing one option of a select box. If the users chooses option1 as subject, his mail program should pop up and open a new mail with the specific email adress.

This is my HTML

<form name="contactUS">
  <select class="mail_box" name="whoExactly" onchange="sendmail()>
    <option value="">Betreff auswählen</option>
    <option value="email1">Bewerbungen</option>
    <option value="email2">Genereller Support / Feedback</option>
    <option value="email3">Anfragen</option>
    <option value="email4">Copyright / Markenrechtverletzungen</option>
    <option value="email5">Sonstiges</option>
  </select>
</form>

And this my not working Javascript

function sendmail(){
 var whoto=contactUs.whoExactly.value;
 location="mailto:" + whoto + "@adress.com";
}

Demo


Solution

  • function sendmail(){
     var whoto=contactUS.whoExactly.value;
     location="mailto:" + whoto + "@adress.com";
    }
    

    note the capital 'S' in contactUS

    http://liveweave.com/U4Q6j2

    Or change your HTML to be camelCase