简体   繁体   English

我可以在 html 页面中保存文本框/下拉菜单选择的值以便再次加载吗?

[英]can i save text boxes / drop down menu chosen values in html page in order to load it again?

I got an html that includes a table with drop-down menus and text boxes.我得到了一个 html,其中包含一个带有下拉菜单和文本框的表格。 the users write their input in the text boxes and choose values in the drop-down menus.用户在文本框中输入他们的输入并在下拉菜单中选择值。 after clicking on 'save' button I want to save the data so if another user will open the page he will see the most updated version.单击“保存”按钮后,我想保存数据,因此如果其他用户打开该页面,他将看到最新版本。 is it possible with JS / HTML ? JS/HTML 有可能吗?

Here two options are available.这里有两个选项可用。 Local Storage and Session Storage . Local StorageSession Storage As per your context you need to go with Local Storage it seems.根据您的上下文,您似乎需要使用Local Storage

The major difference between local storage and session storage is data persistence. local storagesession storage之间的主要区别在于数据持久性。 This means when we use localStorage , data is present and available across various sessions (across multiple windows) ie you can close your browser and come later and any data that has been stored in localStorage will be available to you.这意味着当我们使用localStorage ,数据存在并且可以跨多个会话(跨多个窗口)使用,即您可以关闭浏览器并稍后访问,并且您可以使用存储在localStorage任何数据。 While in Session Storage the data is used only on one browser window which means as soon as we close our window our session keys are destroyed and will not be accessible across sessions.而在Session Storage ,数据仅在一个浏览器窗口上使用,这意味着一旦我们关闭窗口,我们的会话密钥就会被销毁,并且无法跨会话访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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