Hi, with a userscript on this uploaded webpage (saved from the originale) I would like to set
“O2 - SCARTO ORDINARIO 2024” as default option value of the combobox of the popup. This is the html of the combobox:
The popup opens after clicking on the button “Aggiungi a lista”, that has this HTML:
<a title="Aggiungi a lista" data-fn="D_INV_AGGWLIST_DET" href="/sebina/catalogazione/D_INV_AGGWLIST_DET.do?codMenu=15030030100000&codFnz=D_INV_AGGWLIST_DET">
<span class="tooltip"> Aggiungi a lista</span>
This is what I tried without succes, thank you!
// Set the default value
document.getElementById('comboWorklist').value = '231'; // Assuming '231' is the value for "O2 - SCARTO ORDINARIO 2024"
// Trigger the chosen:updated event
var comboWorklist = document.getElementById('comboWorklist');
var event = new Event('chosen:updated');
// Dispatch the event
Triggering the chosen:updated event after changing the original select should work. You can test this on the demo page for chosen. Running these lines in the console will successfully change the value of the country select:
Your code that sets the value and triggers the updated event should work. If it’s not, then what you probably have is a timing problem as mentioned. For example, is your extension waiting for the popup to open before running the code? If not, you might be running it too soon.