我如何将变量:var name = prompt(“”)添加到html中

时间:2017-12-27 20:47:00

标签: javascript html

我如何添加变量: var name = prompt(“给我们发送电子邮件以注册我们的新闻通讯”); 成html,将我的网站时事通讯副本发送给他们?< / p>

我对javascript很新,所以可能有一个明显的答案,但我已经搜索了很多,并没有得到我需要的答案。

h1 {
  font-family: Magneto;
  font-size: 400%;
  color: #ddfdff;
}

form {
  font-family: Magneto;
  font-size: 200%;
  color: #ddfdff;
}

body {
  background-image: url("https://wallpapertag.com/wallpaper/full/d/7/4/341499-free-wallpaper-4k-3840x2160-for-computer.jpg");
  background-size: 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
<!DOCTYPE html>
<html>

<head>
  <title>website</title>
</head>

<body>
  <center>
    <h1>Website Name</h1>
    <center>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <br><br>
      <img src="https://www.encompasscorporation.com/wp-content/uploads/2015/09/white-arrow-down.png" width="100" height="100">
      <h1>Sign up to our newsletter</h1>
      <form action="/action_page.php">
        Full Name<br>
        <input type="text" name="firstname" value="">
        <br> Email
        <br>
        <input type="text" name="lastname" value="">
        <br><br>
        <input type="submit" value="Submit">
      </form>
    </center>
  </center>
</body>

</html>

1 个答案:

答案 0 :(得分:-1)

这是如何获取电子邮件地址的。

我不建议使用提示,但它并不好看。我创建了一个看起来更好的提示 - https://jqueryui.com/dialog/

您还有很多步骤,例如:   1.将数据发送到服务器   2.将其放入数据库   3.创建一个读取该数据库并发送信息的过程。

var name=prompt("Give us your email to sign up to our newsletter")


h1{
  font-family: Magneto;
  font-size: 400%;
  color: white;
}

body{
  background-image: url("https://wallpapertag.com/wallpaper/full/d/7/4/341499-free-wallpaper-4k-3840x2160-for-computer.jpg");
  background-size: 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
}


<!DOCTYPE html>
<html>
<head>
<title>website</title>
</head>
<body>
<center><h1>Website Name</h1></center>
</body>
</html>
<script type="text/javascript">
var name=prompt("Give us your email to sign up to our newsletter")
</script>