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>
for this you could use confirm() and.value of the ID to get the job done like so:
JAVASCRIPT:
function buttonFunction() {
var confirmationFNAME = document.getElementById("fname").value
confirm("Is, " + confirmationFNAME + " the right information?")
var confirmationLNAME = document.getElementById("lname").value
confirm("Is, " + confirmationLNAME + " the right information?")
var confirmationADDRESS = document.getElementById("address").value
confirm("Is, " + confirmationADDRESS + " the right information?")
var confirmationSTATE = document.getElementById("state").value
confirm("Is, " + confirmationSTATE + " the right information?")
var confirmationNUMBER = document.getElementById("number").value
confirm("Is, " + confirmationNUMBER + " the right information?")
}
HTML (added onclick to button):
<!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 onclick = "buttonFunction()" type="submit" id="submit" value="Submit Information"></form>
</br>
</body>
</html>
Hope this helped, if you got any bugs or problems feel free to reach out or comment.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.