Estoy intentando crear una página HTML con un script que almacenará la entrada del usuario en una cadena de consulta y luego se la mostrará al usuario con las etiquetas/descripciones adecuadas en una página de confirmación. Esto es lo que tengo hasta ahora, soy muy nuevo en Javascript pero tengo algo de experiencia con 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>
para esto, podría usar confirm() y .value de la ID para hacer el trabajo así:
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 (agregado al hacer clic en el botón):
<!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>
Espero que esto haya ayudado, si tiene algún error o problema, no dude en comunicarse o comentar.