+ 1

I want a form the can...

I want to make a form that changes another page based on what the user put in. For example I wanted to create a form which has the name, description(leave, vacation) and how many days leaving format. I want the form to only be true if the name is in a JavaScript array. Second I want the description to only show on the username selected in the team.html file. And lastly, I want it to be stored in localstorage and expire when the days run out. The thing I already understand is how to make the function to be true if the name is in the array. I'm having a problem sending the info to the desired name in the other page using the innerhtml and storing it and making it expire after the days described. And for it to remove the name if the description describes it as leave. Here is the code: File name: script.js function info(){ var names=Array["name1","name2","name3","name4"]; let id=0; let ff1=document.getElementById("ff1").value; let ff2=document.getElementById("ff2").value; for(let i=0; i>14;i++){ id++ if(ff1==names[i]){ break document.getElementById("h"+str(id)).innerHTML=ff2; } } } File:index.html <form id="form"> <label for="ff1">Name</label> <input type="text" id="ff1" required> <label for="ff2">Options</label> <select id="ff2" name="Description" required> <option class="option" value="Vacation">Vacation</option> <option class="option" value="Leave">Leave</option> </select> <label for="ff3">How Long?(In days)</label> <input type="numbers" id="ff3" required> <input type="submit" value="Submit" onclick="info()" id="info"> </form> File:team.html <li class="li"><img src="" alt="" class=""><p class="">Name1<p id="h0"></p></p></li> <li class="li"><img src="" alt="" class=""><p class="">Name2<p id="h1"></p></p></li> <li class="li"><img src="" alt="" class=""><p class="">Name3<p id="h2"></p></p></li

27th Jun 2022, 8:58 PM
Coderwe2
Coderwe2 - avatar
3 ответов
+ 3
It would be better for you to link your code as a Code Bit from the Code Playground. • You can go to Code Playground • Select New Code • Select "Web" • Paste your code in the editor • Press Save and then Share here. It's too hard to debug a wall of text and it look like your code is being cut off.
27th Jun 2022, 9:11 PM
Justice
Justice - avatar
27th Jun 2022, 9:28 PM
Coderwe2
Coderwe2 - avatar
0
demo of Single Page App https://code.sololearn.com/W80l0huYVkI5/?ref=app If you want to store it, you need either server side scripting to connect to a database, or localStorage: https://youtu.be/FUnowGWhSxw
28th Jun 2022, 5:19 AM
Gordon
Gordon - avatar