From d29003b7eeb30f618a90e54d8fc7d736f79aa5b6 Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Tue, 26 Sep 2023 09:48:16 +0530 Subject: [PATCH 1/9] arrays --- js/array.js | 93 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 10 deletions(-) diff --git a/js/array.js b/js/array.js index 9b98226..30c440c 100644 --- a/js/array.js +++ b/js/array.js @@ -400,29 +400,102 @@ // console.log(ans); -let data = [ 10, 8, 50, 'meet', 40, 80, 90, 'meet' ]; +// let data = [ 10, 8, 50, 'meet', 40, 80, 90, 'meet' ]; -let data1 = [55, 8, 9, 877, 56, 99, 140]; +// let data1 = [55, 8, 9, 877, 56, 99, 140]; + +// let data2 = ['Mistry','Meet','Surati','Gujarati']; + + +// //8.includes + +// // let ans = data1.includes(55) +// // console.log(ans); -let data2 = ['Mistry','Meet','Surati','Gujarati']; +// //9.every +// // let ans = data1.every((v) => v > 0) +// // console.log(ans); -//8.includes -// let ans = data1.includes(55) +// //10. indexOf + +// // let ans = data.indexOf("meet") +// // console.log(ans); + + +// let ans = data.lastIndexOfayyays("meet") // console.log(ans); -//9.every -// let ans = data1.every((v) => v > 0) + + + +//-----arrays task--------- +//------------------------- + + + +// let data = [20, 49, 10, 'meet', 58, 79]; + +// let data1 = [39, 58, 88, 19, 95, 68] + +// let data2 = ['surat','mumbai','panjab','tamilnadu'] + +// // 1. Finding the maximum element in an array. + +// let ans = data.filter((v, i) => v > 40) // console.log(ans); +// or + +// let ans1 = data.filter((v, i) => { +// if (v > 15) { +// console.log(v); +// } +// }) + + -//10. indexOf -// let ans = data.indexOf("meet") +//2. Finding the minimum element in an array. + + +// let ans = data.filter((v, i) => v < 50) // console.log(ans); -let ans = data.lastIndexOfayyays("meet") +//or + + +// let ans1 = data.filter((v, i) => { +// if (v < 15) { +// console.log(v); +// } +// }) + + + +//3. Sorting an array in ascending order + +// let ans = data2.sort() +// console.log(ans); + +// or + +let ans = data2.sort((v,i) => v - i ) console.log(ans); + + + + + +//4. Sorting an array in descending order. + +// let ans = data1.sort((v,i) => i - v) +// console.log(ans); + +// or + +// let ans = data.sort() +// console.log(ans); \ No newline at end of file From 7a58b13ded903e5056ccf8bc901f6c7327cacc72 Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Tue, 26 Sep 2023 11:28:41 +0530 Subject: [PATCH 2/9] arrays --- arrayFunction.html | 12 ++++++ js/array.js | 90 ++++++++++++++++++++++---------------------- js/arrayFunction.js | 91 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 45 deletions(-) create mode 100644 arrayFunction.html create mode 100644 js/arrayFunction.js diff --git a/arrayFunction.html b/arrayFunction.html new file mode 100644 index 0000000..ecb853e --- /dev/null +++ b/arrayFunction.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/js/array.js b/js/array.js index 30c440c..ef08480 100644 --- a/js/array.js +++ b/js/array.js @@ -62,7 +62,7 @@ -//cahnge +// cahnge // const courses = ["HTML", "CSS", "Javascript"]; // console.log(courses[0]) @@ -70,7 +70,7 @@ // console.log(courses[2]) -//length array Increasing/Decreasing +// length array Increasing/Decreasing // const courses = ["HTML", "CSS", "Javascript", "React"]; @@ -85,7 +85,7 @@ -//We can also update an array after initialization. +// We can also update an array after initialization. // const courses = ["HTML", "CSS", "Javascript"]; // courses.length = 5 // Increasing array length to 5 @@ -108,31 +108,31 @@ // console.log(typeof data); // console.log(data[5]); -//intration +// intration -//1. +// 1. // for (let i = 0; i { // console.log(index + '--' + value); // }); -//3. +// 3. // data.map((value,index) => { // console.log(index + '--' + value); // }) -//4. +// 4. // data.map((v,i) => console.log(i + '--' + v)) @@ -145,7 +145,7 @@ // --Update-- -//1. +// 1. // data[3] = 50 // console.log(data); @@ -157,19 +157,19 @@ // --Add-- -//1. +// 1. // data.push(100); // console.log(data); -//2. +// 2. // data.unshift(100); // console.log(data); -//3. +// 3. // data.splice(5,0,87) // console.log(data); @@ -179,65 +179,65 @@ // --Remove-- -//1. +// 1. // data.pop() // console.log(data); -//2. +// 2. // data.shift() // console.log(data); -//3. +// 3. // data.splice(2,3) // console.log(data); -//------------- +// ------------- // let data = [ 30, 5, 'MISTRY', 80, 60, 'Surti', 50 ]; // let data1 = [88,188]; -//------------- +// ------------- // --Array's Function's-- -//1. +// 1. // let ans = Array.isArray(data); // console.log(ans); -//2. +// 2. // let ans = data.concat(data1) // console.log(ans); -//3. +// 3. // let ans = data.some((v) => v > 50); // console.log(ans); -//4. +// 4. // let ans = data.find((v) => v > 20); // console.log(ans); -//5. +// 5. // let fullname = "MEET NILESHBHAI MISTRY"; // let ans = fullname.split(" "); // console.log(ans); -//6. +// 6. // let ans = data.slice(2,4 ); // console.log(ans); @@ -247,7 +247,7 @@ // -------TASK------- // ------------------ -//1. filter() +// 1. filter() // const Age = [25, 64, 16, 15, 34]; @@ -261,7 +261,7 @@ -//2. reduse() +// 2. reduse() // let arr = [200, 50, 25]; @@ -276,7 +276,7 @@ // callTask() //Ans: 125 - //or +// or @@ -298,7 +298,7 @@ -//3. indexOf() +// 3. indexOf() // function task() { @@ -318,7 +318,7 @@ -//4. lastindexOf +// 4. lastindexOf // function task() { // let lindexOf = 'mistrymeetteem'; @@ -353,17 +353,17 @@ // console.log(ans); -//2.filter +// 2.filter // let ans = data.filter((v,i) => v > 15 && v < 90) // console.log(ans); -//3. reduse +// 3. reduse // let ans = data1.reduce((acc,v,i) => acc + v,0) // console.log(ans); -//4. reverse +// 4. reverse // let ans = data.reverse() // console.log(ans); @@ -371,30 +371,30 @@ -//5. sort +// 5. sort -//1 +// 1 // let ans = data2.sort() // console.log(ans); //asc -//2 +// 2 // let ans = data1.sort((a,b) => a - b) // console.log(ans); -//3 +// 3 // let ans = data1.sort((a,b) => b - a) // console.log(ans); -//6.fill +// 6.fill // let ans = data.fill(10000,2,5) // console.log(ans); -//7.findIndex +// 7.findIndex // let ans = data1.findIndex((v) => v === 56) // console.log(ans); @@ -431,8 +431,8 @@ -//-----arrays task--------- -//------------------------- +// -----arrays task--------- +// ------------------------- @@ -458,14 +458,14 @@ -//2. Finding the minimum element in an array. +// 2. Finding the minimum element in an array. // let ans = data.filter((v, i) => v < 50) // console.log(ans); -//or +// or // let ans1 = data.filter((v, i) => { @@ -476,21 +476,21 @@ -//3. Sorting an array in ascending order +// 3. Sorting an array in ascending order // let ans = data2.sort() // console.log(ans); // or -let ans = data2.sort((v,i) => v - i ) -console.log(ans); +// let ans = data2.sort((v,i) => v - i ) +// console.log(ans); -//4. Sorting an array in descending order. +// 4. Sorting an array in descending order. // let ans = data1.sort((v,i) => i - v) // console.log(ans); diff --git a/js/arrayFunction.js b/js/arrayFunction.js new file mode 100644 index 0000000..92beb12 --- /dev/null +++ b/js/arrayFunction.js @@ -0,0 +1,91 @@ +let array1 = [15, 84, 65, 22, 45, 170, 54] + +//1. + +// const maxArr = (array1) => { +// let max = array1[0] + +// for (let i=1; i max) { +// max = array1[i] +// } +// } +// console.log(max); +// } +// maxArr(array1) + + + +//2. + +// const maxArr = (array1) => { +// let max = array1[0] + +// for (let i=1; i { +// let = newArr =[] +// for (let i=array1.length-1; i>=0; i--) { +// newArr.push(array1[i]); +// } +// console.log(newArr); +// } + +// ReversArr(array1) + +//6. Finding the sum of all elements in an array. + +// const SumArr = () => { +// sum = 0 +// for (let i=0; i { +// sum = 0 +// for (let i=0; i { +// let temp; +// for (let i=0; i Date: Tue, 26 Sep 2023 13:23:20 +0530 Subject: [PATCH 3/9] arrayfunction --- arrayFunction.html | 2 +- js/arrayFunction.js | 61 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/arrayFunction.html b/arrayFunction.html index ecb853e..e6cfa86 100644 --- a/arrayFunction.html +++ b/arrayFunction.html @@ -6,7 +6,7 @@ Document - + \ No newline at end of file diff --git a/js/arrayFunction.js b/js/arrayFunction.js index 92beb12..4bc02a7 100644 --- a/js/arrayFunction.js +++ b/js/arrayFunction.js @@ -1,4 +1,4 @@ -let array1 = [15, 84, 65, 22, 45, 170, 54] +// let array1 = [15, 84, 65, 22, 45, 170, 54] //1. @@ -89,3 +89,62 @@ let array1 = [15, 84, 65, 22, 45, 170, 54] + +//9. Removing duplicates from an array. + +let arr = ["mistry", "meet", "surti","mistry"]; + +let arr1 = [56, 55, 3, "meet", 66, 45, 66, 55,"mistry", 66, 41]; + +let arr2 = ["mistry", "meet", "mistry", "surti", "mistry", "LALA"]; + +// const dupliArr = (arr1) => { +// let newArr = [] +// for (let i=0; i { +// let newArr = [] +// for (let i=0; i { +// let arr4 = [...arr,...arr1]; +// let Merge = [...new Set(arr4)] +// console.log(Merge); +// } +// mergeArr(arr) + + + + +//11. Splitting an array into two arrays based on a condition. + +// const splitArr = (arr,chunk) => { +// let temp; +// for (let i=0; i Date: Wed, 27 Sep 2023 11:27:13 +0530 Subject: [PATCH 4/9] arrays --- js/arrayFunction.js | 97 ++++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/js/arrayFunction.js b/js/arrayFunction.js index 4bc02a7..8931e72 100644 --- a/js/arrayFunction.js +++ b/js/arrayFunction.js @@ -92,59 +92,90 @@ //9. Removing duplicates from an array. -let arr = ["mistry", "meet", "surti","mistry"]; +let arr = ["mistry", "meet", "surti", "mistry"]; -let arr1 = [56, 55, 3, "meet", 66, 45, 66, 55,"mistry", 66, 41]; +let arr1 = [56, 55, 3, 6, 41]; -let arr2 = ["mistry", "meet", "mistry", "surti", "mistry", "LALA"]; +let arr2 = [3, 66, 45, 66, 55, 66, 56, 55, 10]; -// const dupliArr = (arr1) => { -// let newArr = [] -// for (let i=0; i { +// let uniqeArr = [] + +// arr.map((v) => { +// if (!uniqeArr === v) { +// newArr.push(v) // } -// } -// console.log(newArr); +// }) +// console.log(uniqeArr); // } -// dupliArr(arr1) -// const dupliArr = (arr) => { +// dupliArr(arr2) + + + + + + +//10. Merging two arrays into a new array. + +// const mergeArr = (arr1,arr2) => { // let newArr = [] -// for (let i=0; i { -//10. Merging two arrays into a new array. -// const mergeArr = (arr) => { -// let arr4 = [...arr,...arr1]; -// let Merge = [...new Set(arr4)] -// console.log(Merge); // } -// mergeArr(arr) +// splitArr(arr1, aar2) +//13. Rotating an array by a given number of positions. +// const rotatingArr = (arr,n) => { +// for (let i=0; i { -// let temp; -// for (let i=0; i { + +// let ans = arr.sort((a,b) => b-a) +// console.log(ans[1]); // } -// splitArr(arr) \ No newline at end of file + +// seclargArr(arr1) + +// 15. Finding the k-th smallest element in an array. + +// const ksmallArr = (arr, elem) => { +// let ans = arr.sort((a, b) =>a - b) +// console.log(ans[elem - 1]); +// } +// ksmallArr(arr1, 2) + From 52487755dad08133bec6b06264e951b64ce4fa02 Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Sat, 30 Sep 2023 11:19:20 +0530 Subject: [PATCH 5/9] array --- js/test3.js | 28 ++++++++++++++++++++++++++++ test3.html | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 js/test3.js create mode 100644 test3.html diff --git a/js/test3.js b/js/test3.js new file mode 100644 index 0000000..ede250f --- /dev/null +++ b/js/test3.js @@ -0,0 +1,28 @@ +let arr1 = []; + +const Remove = () => { + arr1.slice() +} + +const handlSubmit = () => { + // console.log("ok"); + event.preventDefault() + + let name = document.getElementById("name").value + // console.log(name); + + let addName = arr1.push(name) + // console.log(addName); + + if (arr1) { + let print = ""; + arr1.map((v, i) => { + print += `
  • ${arr1[i]}` + print += `` + }); + document.getElementById("input").innerHTML = print; + } + + return false; +} + diff --git a/test3.html b/test3.html new file mode 100644 index 0000000..83eac17 --- /dev/null +++ b/test3.html @@ -0,0 +1,20 @@ + + + + + + Document + + + +
    + + +
    + + +
    + + + + \ No newline at end of file From 6445c88c2edb3af94e7d41c21ac0d15f6bf3d4b0 Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Mon, 2 Oct 2023 11:28:45 +0530 Subject: [PATCH 6/9] todo --- 2darray.html | 17 +++++++++++++++++ js/2darray.js | 21 +++++++++++++++++++++ js/test3.js | 50 ++++++++++++++++++++++++++++++++++++-------------- test3.html | 1 - 4 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 2darray.html create mode 100644 js/2darray.js diff --git a/2darray.html b/2darray.html new file mode 100644 index 0000000..399ea59 --- /dev/null +++ b/2darray.html @@ -0,0 +1,17 @@ + + + + + + Document + + + +
    + + +
    + + + + \ No newline at end of file diff --git a/js/2darray.js b/js/2darray.js new file mode 100644 index 0000000..43314f2 --- /dev/null +++ b/js/2darray.js @@ -0,0 +1,21 @@ +let arr = [ + [1,'meet',21] + [2,'dixit',20] + [3,'dhruvil',22] +] + +const display = (arr) => { + + let print = '' + + + for (let i=0; i { + arr1.splice(i,1) + + Display() +} + +const handleEdit = (i) => { + update = i; + document.getElementById("name").value = arr1[i] +} + +const Display = () => { + + let print = '
      ' + + arr1.map((v, i) => { + print += `
    • ${v}
    • ` + }); + + print += '
    ' + document.getElementById("input").innerHTML = print -const Remove = () => { - arr1.slice() } const handlSubmit = () => { // console.log("ok"); event.preventDefault() - let name = document.getElementById("name").value - // console.log(name); + let name = document.getElementById("name").value - let addName = arr1.push(name) - // console.log(addName); + if (update != null || update === 0) { + console.log("update operation"); + arr1[update] = name + update = null; - if (arr1) { - let print = ""; - arr1.map((v, i) => { - print += `
  • ${arr1[i]}` - print += `` - }); - document.getElementById("input").innerHTML = print; + } else { + console.log("Add operation"); + arr1.push(name) } - return false; + document.getElementById("name").value = " " + // arr1.push(name) + + Display() + } diff --git a/test3.html b/test3.html index 83eac17..db71dfe 100644 --- a/test3.html +++ b/test3.html @@ -12,7 +12,6 @@
    - From fee187d8622b8ab8d7ab22ec056474ae9510cc50 Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Wed, 4 Oct 2023 11:35:21 +0530 Subject: [PATCH 7/9] dom --- test3.html => dom.html | 13 ++++++---- js/dom.js | 55 ++++++++++++++++++++++++++++++++++++++++++ js/object.js | 0 js/test3.js | 50 -------------------------------------- js/todo.js | 42 ++++++++++++++++++++++++++++++++ objects.html | 12 +++++++++ todo.html | 21 ++++++++++++++++ 7 files changed, 138 insertions(+), 55 deletions(-) rename test3.html => dom.html (55%) create mode 100644 js/dom.js create mode 100644 js/object.js delete mode 100644 js/test3.js create mode 100644 js/todo.js create mode 100644 objects.html create mode 100644 todo.html diff --git a/test3.html b/dom.html similarity index 55% rename from test3.html rename to dom.html index db71dfe..26377aa 100644 --- a/test3.html +++ b/dom.html @@ -7,13 +7,16 @@ -
    - + + + + -
    - +
    - +
    + + \ No newline at end of file diff --git a/js/dom.js b/js/dom.js new file mode 100644 index 0000000..929bd49 --- /dev/null +++ b/js/dom.js @@ -0,0 +1,55 @@ +// const handlClick = () => { +// console.log("Click!!"); +// } +// let divElem = document.getElementById("disp"); +// let h1Elem = document.createElement("h1"); +// let h1Text = document.createTextNode("Hello"); + +// h1Elem.appendChild(h1Text); + +// divElem.appendChild(h1Elem); + +// let aElem = document.createElement("a"); +// aElem.setAttribute("href","#"); +// aElem.setAttribute("onclick","handlClick()") +// let aText = document.createTextNode("home"); + +// aElem.appendChild(aText); +// divElem.appendChild(aElem); + + +const handlRemove = (id) => { + let div = document.getElementById("div-", + id) + console.log("remove"); + div.remove() + + +} +const handlSubmit = () => { + event.preventDefault() + + let name = document.getElementById("name").value; + console.log("ok"); + + let id = Math.floor(Math.random() * 1000); + console.log(id); + + + let parentDiv = document.getElementById("disp"); + let divElem = document.createElement("div"); + divElem.setAttribute("id","div-" + id); + let divText = document.createTextNode(name); + + let btnElem = document.createElement("button"); + btnElem.setAttribute("onclick","handlRemove("+ id +")"); + + let btnText = document.createTextNode("X"); + + divElem.appendChild(divText); + parentDiv.appendChild(divElem); + + btnElem.appendChild(btnText); + parentDiv.appendChild(btnElem); + + +} \ No newline at end of file diff --git a/js/object.js b/js/object.js new file mode 100644 index 0000000..e69de29 diff --git a/js/test3.js b/js/test3.js deleted file mode 100644 index a3cc461..0000000 --- a/js/test3.js +++ /dev/null @@ -1,50 +0,0 @@ -let arr1 = []; -let update = null - -const handleDelete = (i) => { - arr1.splice(i,1) - - Display() -} - -const handleEdit = (i) => { - update = i; - document.getElementById("name").value = arr1[i] -} - -const Display = () => { - - let print = '
      ' - - arr1.map((v, i) => { - print += `
    • ${v}
    • ` - }); - - print += '
    ' - document.getElementById("input").innerHTML = print - -} - -const handlSubmit = () => { - // console.log("ok"); - event.preventDefault() - - let name = document.getElementById("name").value - - if (update != null || update === 0) { - console.log("update operation"); - arr1[update] = name - update = null; - - } else { - console.log("Add operation"); - arr1.push(name) - } - - document.getElementById("name").value = " " - // arr1.push(name) - - Display() - -} - diff --git a/js/todo.js b/js/todo.js new file mode 100644 index 0000000..ebe1c4f --- /dev/null +++ b/js/todo.js @@ -0,0 +1,42 @@ +let array = []; +let update = null; + +const handleremove = (i) => { + + array.splice(i , 1); + + display(); +} +const handleEdit = (i) => { + update = i; + document.getElementById("name").value = array[i]; + +} + +const display = () => { + let ulElem = document.getElementById("disp"); + + let liElem = document.createElement("li"); + let liText = document.createTextNode("100"); + + liElem.appendChild(liText); + ulElem.appendChild(liElem); + + + +} + +const handledetail = () => { + event.preventDefault(); + let name = document.getElementById("name").value; + + if (update !== null || update == 0) { + array[update] = name; + } else { + array.push(name); + } + update = null; + document.getElementById("name").value = ""; + + display(); +} \ No newline at end of file diff --git a/objects.html b/objects.html new file mode 100644 index 0000000..712e43a --- /dev/null +++ b/objects.html @@ -0,0 +1,12 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/todo.html b/todo.html new file mode 100644 index 0000000..19d8f0f --- /dev/null +++ b/todo.html @@ -0,0 +1,21 @@ + + + + + + Document + + + +
    + + + + + +
      + +
    + + + \ No newline at end of file From e4b2037f3eda16f872c41ac8af6648c426adca4d Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Thu, 5 Oct 2023 11:25:51 +0530 Subject: [PATCH 8/9] localstorage --- hotelbill.html | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ js/dom.js | 1 - js/hotelbill.js | 0 js/storage.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ storage.html | 20 +++++++++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 hotelbill.html create mode 100644 js/hotelbill.js create mode 100644 js/storage.js create mode 100644 storage.html diff --git a/hotelbill.html b/hotelbill.html new file mode 100644 index 0000000..2f2e586 --- /dev/null +++ b/hotelbill.html @@ -0,0 +1,53 @@ + + + + + + Hotel Bill + + + +

    Hotel Bill Colelection System

    + +
    + +

    Select Date

    + +

    + +

    Select Table

    + + +

    + +

    Select Food

    + +

    + + +

    + + + + + + + + \ No newline at end of file diff --git a/js/dom.js b/js/dom.js index 929bd49..8c7e86d 100644 --- a/js/dom.js +++ b/js/dom.js @@ -23,7 +23,6 @@ const handlRemove = (id) => { console.log("remove"); div.remove() - } const handlSubmit = () => { event.preventDefault() diff --git a/js/hotelbill.js b/js/hotelbill.js new file mode 100644 index 0000000..e69de29 diff --git a/js/storage.js b/js/storage.js new file mode 100644 index 0000000..a1d7ff9 --- /dev/null +++ b/js/storage.js @@ -0,0 +1,53 @@ +// localStorage.setItem('firstname','meet') +// localStorage.setItem('lastname','mistry') +// // console.log(localStorage.getItem('firstname')); +// localStorage.removeItem('lastname') + + + +// // sessionStorage.setItem('location','surat') +// // sessionStorage.removeItem('location') + +// // console.log(sessionStorage.getItem('location')); + + + +const handlSubmit = () => { + + + let localdata = JSON.parse(localStorage.getItem("name")); + + let name = document.getElementById("name").value; + + console.log(name); + + if (localdata) { + localdata.push(name); + + localStorage.setItem("name", JSON.stringify(localdata)); + } else { + + localStorage.setItem("name", JSON.stringify([name])); + } + + + // arr.push(name); + +} + +const Display = () => { + let data = JSON.parse(localStorage.getItem("name")); + let disElem = document.getElementById("disp") + disElem.innerHTML = "" + + + data.map((l) => { + let liElem = document.createElement("li"); + let liText = document.createTextNode(l) + + liElem.appendChild(liText); + disElem.appendChild(liElem); + }); +} + +Display() \ No newline at end of file diff --git a/storage.html b/storage.html new file mode 100644 index 0000000..9c38e22 --- /dev/null +++ b/storage.html @@ -0,0 +1,20 @@ + + + + + + Document + + +
    + + + + +
      + +
    + + + + \ No newline at end of file From ff4673ea59f3e2a41e7ad931a908169703a515fc Mon Sep 17 00:00:00 2001 From: yashbhalani8866 Date: Fri, 6 Oct 2023 11:31:26 +0530 Subject: [PATCH 9/9] hotel --- hotelbill.html | 79 +++++++++++++----------- js/hotelbill.js | 158 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 36 deletions(-) diff --git a/hotelbill.html b/hotelbill.html index 2f2e586..d12c031 100644 --- a/hotelbill.html +++ b/hotelbill.html @@ -6,48 +6,55 @@ Hotel Bill - -

    Hotel Bill Colelection System

    - -
    - -

    Select Date

    - -

    - -

    Select Table

    - +
    + +
    +

    Table

    + - -

    - -

    Select Food

    - + - + +
    + +

    Person

    + +
    +

    - - -

    - - - +

    +
  • sr nonameage
    + + + + + + + +
    DateTableFoodNo Of PersonTotal Bill
    + - \ No newline at end of file diff --git a/js/hotelbill.js b/js/hotelbill.js index e69de29..00abedb 100644 --- a/js/hotelbill.js +++ b/js/hotelbill.js @@ -0,0 +1,158 @@ +const handlesubmit = () => { + let date = document.getElementById("date").value; + let table = document.getElementById("table").value; + let food = document.getElementById("food").value; + let person = document.getElementById("person").value; + + let obj = { + date: date, + table: table, + food: food, + person: person + } + console.log(obj); + + let localdata = JSON.parse(localStorage.getItem("hotel")); + + if (localdata) { + localdata.push(obj) + localStorage.setItem("hotel", JSON.stringify(localdata)) + } else { + localStorage.setItem("hotel", JSON.stringify([obj])) + } + display() +} +// let dateErr = true; +// let tableErr = true; +// let foodErr = true; +// let personErr = true; + +// console.log(date , table , food , person); +// if (date === "") { +// document.getElementById("dateErr").innerHTML = "Please Select Date"; +// document.getElementById("dateErr").style.color = "red"; +// }else{ +// document.getElementById("dateErr").innerHTML = ""; +// dateErr = false; +// } +// if(table === "0"){ +// document.getElementById("tableErr").innerHTML = "Please Select Table"; +// document.getElementById("tableErr").style.color = "red"; +// }else{ +// document.getElementById("tableErr").innerHTML = ""; +// tableErr = false; +// } +// if (food === "0") { +// document.getElementById("foodErr").innerHTML = "Please Select Food"; +// document.getElementById("foodErr").style.color = "red"; +// }else{ +// document.getElementById("foodErr").innerHTML = ""; +// foodErr = false; + +// } +// if (person === '' || person === "0" ) { +// document.getElementById("personErr").innerHTML = "Please Enter Person"; +// document.getElementById("personErr").style.color = "red"; + +// }else{ +// document.getElementById("personErr").innerHTML = ""; +// personErr = false; +// } + +// localStorage.setItem("dateDetail" , JSON.stringify(date)); +// localStorage.setItem("tableDetail" , JSON.stringify (table)); +// localStorage.setItem("foodDetail" , JSON.stringify(food)); +// localStorage.setItem("personDetai" , JSON.stringify(person)); +// + + +const display = () => { + let hoteldisp = JSON.parse(localStorage.getItem("hotel")); + + let display = document.getElementById("disp"); + display.innerHTML = "" + + let trElem = document.createElement("tr"); + let tdElem = document.createElement("th"); + let tdText = document.createTextNode(v.date); + + tdElem.appendChild(tdText); + trElem.appendChild(tdElem); + display.appendChild(trElem); + + + let tdElem1 = document.createElement("th"); + let tdText1 = document.createTextNode(v.table); + + + tdElem1.appendChild(tdText1); + trElem.appendChild(tdElem1); + + + let tdElem2 = document.createElement("th"); + let tdText2 = document.createTextNode(v.food); + + + tdElem2.appendChild(tdText2); + trElem.appendChild(tdElem2); + + + let tdElem3 = document.createElement("th"); + let tdText3 = document.createTextNode(v.person); + + + tdElem3.appendChild(tdText3); + trElem.appendChild(tdElem3); + + + let tdElem4 = document.createElement("th"); + let tdText4 = document.createTextNode(v.total); + + + tdElem4.appendChild(tdText4); + trElem.appendChild(tdElem4 ); + + + hoteldisp.map((v,i) => { + let trElem = document.createElement("tr"); + let tdElem = document.createElement("td"); + let tdText = document.createTextNode(v.date); + + tdElem.appendChild(tdText); + trElem.appendChild(tdElem); + display.appendChild(trElem); + + + let tdElem1 = document.createElement("td"); + let tdText1 = document.createTextNode(v.table); + + + tdElem1.appendChild(tdText1); + trElem.appendChild(tdElem1); + + + let tdElem2 = document.createElement("td"); + let tdText2 = document.createTextNode(v.food); + + + tdElem2.appendChild(tdText2); + trElem.appendChild(tdElem2); + + + let tdElem3 = document.createElement("td"); + let tdText3 = document.createTextNode(v.person); + + + tdElem3.appendChild(tdText3); + trElem.appendChild(tdElem3); + + + let tdElem4 = document.createElement("td"); + let tdText4 = document.createTextNode(v.total); + + + tdElem4.appendChild(tdText4); + trElem.appendChild(tdElem4 ); + }); +} +display() \ No newline at end of file