Lisa85,
formatting
<script>
$(document).ready(() => {
$('#buttonX').on('click', () => {
const value = $('#textX').val();
if (value) {
storage(value);
window.location.href = '?value='+value;
} else {
alert('Empty!');
}
});
const values = storage();
$('#selectX').append(values.reduce((prev, value) => prev+'<option>'+value+'</option>', ''));
});
function storage(data) {
const _data = JSON.parse(sessionStorage.getItem('data')) || [];
if (data) {
_data.push(data);
sessionStorage.setItem('data', JSON.stringify(_data));
}
return _data;
}
</script>
<input id="textX">
<select id="selectX"></select>
<button id="buttonX">Button</button>