html - 如何发送到电子邮件 - select 标签值和输入值?

html - how to send to email both - select tag value and input value?

<!DOCTYPE html>
<html>
<body>

<form action="" method="post" enctype="text/plain">
IP Address:<br>
<input type="text" name="" placeholder=""><br>
Port:<br>
<input type="text" name="" placeholder=""><br>
Game:<br>
<input type="text" name="" placeholder="" ><br>
Type:<br>
<input type="option" name="Type" size="50"><br><br>
<select name="cars">
    <option value="volvo">Volvo XC90</option>
    <option value="saab">Saab 95</option>
    <option value="mercedes">Mercedes SLK</option>
    <option value="audi">Audi TT</option>
  </select>

<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
</body>
</html>

我想在写正确的操作时将其发送到邮件="mailto:....." 我只能发送输入内容,但不能发送 select 标签 selected 选项我尝试了任何这些东西单独使用它可以工作但是当我想用一个按钮做到这一点时它不起作用......

您可以在 HTML 中使用这样的东西:

<script src="https://code.jquery.com/jquery-3.1.0.js"></script>

<input type="email" name="email" placeholder="Email" id="Email"><br>
<input type="text" name="titre" placeholder="Title" id="Title"><br>
<textarea name="content" placeholder="Content" id="Content"></textarea><br>
<button id="send">send</button>

现在使用 jquery 添加:

$("#send").click(function(){
   var email=$('#Email').val();
   var title=$('#Title').val();
   var content=$('#Content').val();
   document.location.href = "mailto:"+email+"?subject="+title+"&body="+content;
});

对于 select 中的选项标签,您必须知道您只能从 select 标签

中的选项发送 selected 值

希望对您有所帮助。