-
Notifications
You must be signed in to change notification settings - Fork 0
/
form1.html
83 lines (73 loc) · 2.63 KB
/
form1.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html>
<head>
<title>User Input Example</title>
<style>
#output {
font-size: 20px;
font-weight: bold;
margin-top: 20px;
}
.swiper-slide {
background-color: #f2f2f2;
padding: 10px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<form>
<p>Please selct your work</p>
<input type="radio" id="florists" name="work">
<label for="Florists">Florists</label><br>
<input type="radio" id="Craters" name="work">
<label for="Craters">Craters</label><br>
<input type="radio" id="Photographers" name="work">
<label for="Photographers">Photographers</label><br>
<input type="radio" id="DJ services" name="work">
<label for="DJ services">DJ services</label><br>
<input type="radio" id="Evnet Decorators" name="work">
<label for="Evnet Decorators">Evnet Decorators</label><br>
<br>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<label for="address">Address:</label><br>
<input type="text" id="address" name="address"><br><br>
<label for="contact">Phone Number:</label><br>
<input type="text" id="contact" name="contact"><br><br>
<button type="button" onclick="showOutput()">Submit</button>
</form>
<div id="output"></div>
<script>
function showOutput() {
const fname = document.getElementById("fname").value;
const lname = document.getElementById("lname").value;
const address = document.getElementById("address").value;
const contact = document.getElementById("contact").value;
const newDiv = document.createElement("div");
newDiv.className = "swiper-slide";
newDiv.innerHTML = fname + " " + lname + "<br>" + address + "<br>" + contact + "<br>";
fetch("index.html")
.then(response => response.text())
.then(html => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
const container = doc.querySelector("#container1");
container.appendChild(newDiv);
const serializer = new XMLSerializer();
const newHtml = serializer.serializeToString(doc);
const fs = require("fs");
fs.writeFile("index.html", newHtml, function (err) {
if (err) throw err;
console.log("index.html updated.");
});
})
.catch(error => {
console.error(error);
});
}
</script>
</body>
</html>