In: Computer Science
<!DOCTYPE html>
<html lang="en">
<head>
<title>Form Display Example</title>
<script type="text/javascript">
function display() {
dispWin =
window.open('','NewWin','toolbar=no,status=no,width=300,height=200')
message = "<ul><li>NAME:" +
document.form1.name.value;
message += "<li>ADDRESS:" +
document.form1.address.value;
message += "<li>PHONE:" +
document.form1.phone.value;
message += "</ul>";
dispWin.document.write(message);
}
</script>
</head>
<body>
<h1>Form Display Example</h1>
<p>Enter the following information. When you
press the Display button, the data you entered will be displayed in
a pop-up.</p>
<form name="form1" method="get" action="">
<p>NAME: <input type="text" name="name"
size="50" /></p>
<p>ADDRESS: <input type="text" name="address"
size="50" /></p>
<p>PHONE: <input type="text" name="phone"
size="50" /></p>
<p><input type="button" value="Display"
onclick="display();" /></p>
</form>
</body>
</html>
Above is the code from the text and below is the edits that I am having trouble adding to the assisnment.
Using Notepad++, copy the code presented in Listing 26.2, "A Form That Displays Data in a Pop-Up Window," in the subsection "Displaying Data From a Form" in the section "Accessing Form Elements With JavaScript" in Ch. 26, "Working with Web-Based Forms of Sams Teach Yourself HTML, CSS and JavaScript All In One. Save the file using the name Week4ValidationExample.html. Test your code and debug as necessary.
Change the name of the display() function to myDisplay() where my is your first name. For example, if your first name were Sam, your display function would be SamDisplay(). Test your code and debug as necessary.
Change the width and height of the pop-up window in which you have set the feedback to appear as 250 and 400, respectively. Test your code and debug as necessary.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Form Display Example</title>
<script type="text/javascript">
function SamDisplay() {
dispWin =
window.open('','NewWin','toolbar=no,status=no,width=250,height=400')
message = "<ul><li>NAME:" +
document.form1.name.value;
message += "<li>ADDRESS:" +
document.form1.address.value;
message += "<li>PHONE:" + document.form1.phone.value;
message += "</ul>";
dispWin.document.write(message);
}
</script>
</head>
<body>
<h1>Form Display Example</h1>
<p>Enter the following information. When you press the
Display button, the data you entered will be displayed in a
pop-up.</p>
<form name="form1" method="get" action="">
<p>NAME: <input type="text" name="name" size="50"
/></p>
<p>ADDRESS: <input type="text" name="address" size="50"
/></p>
<p>PHONE: <input type="text" name="phone" size="50"
/></p>
<p><input type="button" value="Display"
onclick="SamDisplay();" /></p>
</form>
</body>
</html>
Please let me know if you have any doubt or modify the answer, Thanks :)