-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfinal_js_autocomplete.html
52 lines (48 loc) · 2.01 KB
/
final_js_autocomplete.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!-- Created by Garvit Khurana -->
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Shipping and Billing</title>
<style>
input{
border:1px solid black;
}
input:focus{
background-color: #E6E6E6;
}
fieldset{
margin-bottom: 4%;
}
</style>
<script type="text/javascript">
function billingFunction()
{
if (document.getElementById('same').checked){
document.getElementById("billingName").value=document.getElementById("shippingName").value;
document.getElementById("billingZip").value=document.getElementById("shippingZip").value;
}
else{
document.getElementById("billingName").value="";
document.getElementById("billingZip").value="";
}
}
</script>
</head>
<body>
<h1>JavaScript Homework</h1>
<p>Add the JavaScript code needed to enable auto-complete on this form. Whenever the checkbox is checked, the code should automatically copy the values from Shipping Name and Shipping Zip into the Billing Name and Billing Zip. If the checkbox is unchecked, the Billing Name and Billing Zip should go blank.</p>
<form>
<fieldset>
<legend>Shipping Information</legend> <label for ="shippingName">Name:</label> <input type = "text" name = "Name" id = "shippingName" required><br/>
<label for = "shippingzip">Zip code:</label> <input type = "text" name = "zip" id = "shippingZip" pattern = "[0-9]{5}" required><br/>
</fieldset>
<input type="checkbox" id="same" name="same" onchange= "billingFunction()"/>
<label for = "same">Is the Billing Information the Same?</label>
<fieldset>
<legend>Billing Information</legend> <label for ="billingName">Name:</label> <input type = "text" name = "Name" id = "billingName" required><br/>
<label for = "billingzip">Zip code:</label> <input type = "text" name = "zip" id = "billingZip" pattern = "[0-9]{5}" required><br/>
</fieldset>
<input type = "submit" value = "Verify"/>
</form>
</body>
</html>