So I have a script that appends text boxes and I want to save the text boxes, by this I mean when I reopen the app it will load the text boxes with their value and stuff. I am asking this question because I have searched the answer for 2 days and still can't find anything related to this. Any help will be appreciated!
<body>
<form class="myformclass" style="font-family: sans-serif;font-size:20px;" id="myForm" onsubmit="return validateForm()">
<input class="addcommandbtn"type="button" id="addCommand" style="width: 6.5%;" value="+ Command">
<input class="addcommandbtn"type="button" id="removeCommand" style="width: 7.2%;" value="- Command" onclick="removeCommandFunc()">
<input class="addcommandbtn"type="button" id="saveCommands" style="width: 4.2%;" value="Save Commands" onclick="SaveToLocalStorage()">
<input class="addcommandbtn"type="button" id="loadCommands" style="width: 4.2%;" value="load Commands" onclick="load()">
<select name="commandslist" id="commandslist" size="18%" style="height: 59%;width: 15%; display: block; border: 1px solid #dcdcdc; border-radius: 6px; margin-top: 5px;"></select>
</form>
</body>
<script>
function showmenu() {
ipcRenderer.invoke('chooseloc');
}
function commadnspage() {
location.href="./commands.html";
}
function homepage(){
location.href="./index.html";
}
function removeCommandFunc() {
var d = document.getElementById("commandslist");
d.remove(d.selectedIndex);
}
</script>
<script>
const { ipcRenderer } = require('electron');
</script>
<script>
var commands = [];
function createCommandField() {
var input = document.createElement('option');
input.style.marginTop = "1%";
input.textContent = "command";
input.name = 'Commands[]';
input.style.display = 'block'
input.style.boxShadow = 'inset 0px 1px 0px 0px #ffffff';
input.style.border = '1px solid #dcdcdc';
input.style.borderRadius = '6px';
input.style.height = "2%";
input.style.padding = '5px 30px';
input.style.fontFamily="Arial";
input.style.fontWeight="bold";
input.style.fontSize="17px";
commands.push(input);
return input;
}
function SaveToLocalStorage(){
localStorage.setItem('commands', JSON.stringify(commands));
}
function load(){
document.getElementById('commandslist').appendChild(localStorage.getItem(`commands`, JSON.parse(commands)));
}
var select = document.getElementById('commandslist');
document.getElementById('addCommand').addEventListener('click', function (e) {
select.appendChild(createCommandField());
});
</script>