So, I have a form that accepts values and on submit appends the values to another form in multiple tabs.
I'm trying to select the second option of a dropdown if the user chose IT or ES.
Here is my greasemonkey:
var taxcty = document.getElementById("CountryCode");
if (taxcty.options[taxcty.selectedIndex].value == 'IT' || 'ES'){
(document.querySelector && document.querySelector('select[name="currentState"]') || []).value = 'Unverified';
}
So in theory, if the user selects IT or ES in the "CountryCode" field, I want the currentState field to change to "Unverified".
It's partially working right now but it is also changing all other country codes to Unverified lol. So if I chose "GB" it actually changes to Unverified but I only want it to do that for IT or ES.
if (taxcty.options[taxcty.selectedIndex].value == 'IT' || taxcty.options[taxcty.selectedIndex].value == 'ES'){
You need to have both sides of the comparison for all values. 'ES' as a standalone operand will always be true as it is not null, empty or false.