Pre Set Select Option

i want to pre-select this input when page loads but when I add the a value it goes blank
const input1 = document.querySelector('.publicationsList #type');
const input2 = document.querySelector('.publicationsList #year');
const input3 = document.querySelector('.publicationsList #researchAreas');
const input4 = document.querySelector('.publicationsList #author');

input1.value = '2022';
const input1 = document.querySelector('.publicationsList #type');
const input2 = document.querySelector('.publicationsList #year');
const input3 = document.querySelector('.publicationsList #researchAreas');
const input4 = document.querySelector('.publicationsList #author');

input1.value = '2022';
No description
3 Replies
Jochem
Jochemā€¢3mo ago
2022 doesn't look like a value for a field called type to me are you sure there's an option in #type with the value '2022'?
Aldrin
Aldrinā€¢3mo ago
actually it was not showing up because of the white space before string
Jochem
Jochemā€¢3mo ago
ah, good to know you've solved it šŸ™‚