Retain dynamically submitted select options on form submit

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Retain dynamically submitted select options on form submit



I have an html form with a dynamically populated select:


<form action="/" method="post" onsubmit="beforeSubmit()" id="crypto_form">
<textarea name="message" id="textarea_message" oninput="this.value.toUpperCase()" cols="60" rows="5" placeholder="Enter Message"></textarea>
<select form="crypto_form" name="keydata" id="select_keydata"></select>
<button type="submit" name="type" id="btn_encrypt" value="encrypt">Encrypt</button>
<button type="submit" name="type" id="btn_decrypt" value="decrypt">Decrypt</button>
</form>



The problem is that when I submit the form, all select values disappear. How do I retain them when I submit the form? I looked at similar questions to this, but none of them solve my particular case.



I'm using golang as a backend.



Note: The beforeSubmit() function is empty. Anything I can put in there to retain the options?


beforeSubmit()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results