简体   繁体   中英

How to keep the values in a form after getting redirected from another page(like a confirmation page) after submitting the form

This question is not about traditionally keeping the values in form after form submission. I am creating an E-learning portal where I have to create a functionality where I need to make questions for test papers. I have created a form as shown in the picture here:- 链接到我的表格

Now when I submit the form after filling all the values , it is going to redirect me to a confirmation page saying "Do you want to enter another question".If I click on yes it should redirect me to the same page to create the question as shown in picture I have attached but this time the form should have already entered values which I entered before submitting the earlier question. For example, Take a paragraph comprehension question.You don't need to enter the paragraph again and again, you just have to enter the question you need to ask on that comprehension.Consider this as the base of my program.

Please help me and guide me how to create such functionality. Thanks in advance.

You can use localStorage from javascript to keep and set your data.

// To get
if(localStorage.getItem('your-datas')){
    var datas = JSON.parse(localStorage.getItem('your-datas'));  
}
// To set
var myData = {section: $("#section").val(),...};
localStorage.setItem('your-datas', JSON.stringify(myData));

Here the link with a basic usage: https://www.w3schools.com/html/html5_webstorage.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM