-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (62 loc) · 1.75 KB
/
Copy pathscript.js
File metadata and controls
70 lines (62 loc) · 1.75 KB
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
const form = document.querySelector("#form");
form.addEventListener("submit", (e) => {
if (!validate()) {
e.preventDefault();
}
});
function validate() {
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
var error = document.getElementById("error1");
if (email == "tracker@gmail.com" && password == "tracker") {
window.location.assign("dashbord.html");
error.textContent = "";
return false;
} else {
error.textContent = "Invlaid crendiential";
return false;
}
}
//! for api fatch
fetch("https://randomuser.me/api/?results=10")
.then((res) => {
console.log(res);
return res.json();
})
.then((data) => {
console.log(data);
let markup = [];
let names = [];
let email = [];
let city = [];
for (let i = 0; i < 10; i++) {
names = `<h1>${data.results[i].name.first}</h1>
`;
email = `<h3>${data.results[i].email}</h3>
`;
city = `<h3>${data.results[i].location.city}</h3>
`;
markup = `<img src="${data.results[i].picture.large}"></img>
`;
document.querySelector("p").insertAdjacentHTML("beforeend", markup);
document.querySelector("h4").insertAdjacentHTML("beforeend", names);
document.querySelector("h4").insertAdjacentHTML("beforeend", email);
document.querySelector("h4").insertAdjacentHTML("beforeend", city);
}
})
.catch((error) => console.log(error));
const body = document.querySelector(".all");
let cd = "";
for(let i = 1 ; i <= 10 ; i++){
cd+=`
<div class="container">
<div class="cards">
<div class="side-cards">
<div class="dummy">
</div>
</div>
</div>
</div>
`;
}
body.innerHTML=cd;