如何使用HTML的用户输入在JavaScript中制作确认页面
我正在尝试使用一个将用户输入存储在查询字符串中的脚本的HTML页面,然后在确认页面中使用适当的标签/说明显示给用户。这是我到目前为止的目标,我对JavaScript非常新,但对HTML有一定的经验。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bob's Pet Store</title>
<script src="petshop.js"></script>
</head>
<body>
<form id="myForm">
<h1>Place your customer information below!</h1>
<h2>Customer Information:</h2>
<h3>Please enter the neccessary information.</h3>
<p>First Name: <input type="text" id="fname" /></p>
<p>Last Name: <input type="text" id="lname" /></p>
<p>Email Address: <input type="text" id="address" /></p>
<p>State: <input type="text" id="state" /></p>
<p>Phone Number: <input type="text" id="number" /></p>
<br></br>
<br><input type="submit" id="submit" value="Submit Information"></form>
</br>
</body>
</html>
I'm attempting to make an HTML page with a script that will store the user's input in a query string, then display it back to the user with the appropriate labels/descriptions in a confirmation page. This is what I have so far, I'm very new to Javascript but have some experience with HTML.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Bob's Pet Store</title>
<script src="petshop.js"></script>
</head>
<body>
<form id="myForm">
<h1>Place your customer information below!</h1>
<h2>Customer Information:</h2>
<h3>Please enter the neccessary information.</h3>
<p>First Name: <input type="text" id="fname" /></p>
<p>Last Name: <input type="text" id="lname" /></p>
<p>Email Address: <input type="text" id="address" /></p>
<p>State: <input type="text" id="state" /></p>
<p>Phone Number: <input type="text" id="number" /></p>
<br></br>
<br><input type="submit" id="submit" value="Submit Information"></form>
</br>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您可以使用ID的确认()和.value来完成工作:
javascript:
html(添加到按钮中):
希望这有帮助,如果您有任何错误或问题,请随时接触或发表评论。
for this you could use confirm() and .value of the ID to get the job done like so:
JAVASCRIPT:
HTML (added onclick to button):
Hope this helped, if you got any bugs or problems feel free to reach out or comment.