![](/img/trans.png)
[英]How do I make a text box appear after selecting an option from a drop-down menu in SuiteScript?
[英]Selecting a drop-down box option does not affect page
我正在嘗試制作一個擴展程序,以使其便於在網站的結帳頁面上填寫信息(您可能必須先添加到購物車,然后才能轉到結帳頁面)。 當前,我只是將某個option
標簽的“ selected”值設置為true,但似乎並未按預期影響頁面。 我在結帳頁面上談論的是“國家和州”選擇(我希望它是加拿大和不列顛哥倫比亞省)。 傾向於香草Javascript
這是我的代碼:
var checkoutSelects = document.querySelectorAll("select:not([type=hidden])");
for(var i = 0; i < checkoutSelects.length; i++) {
if(checkoutSelects[i].getAttribute("id").toLowerCase().includes('country')) {
var countryOptions = checkoutSelects[i].querySelectorAll('option');
for(var a = 0; a < countryOptions.length; a++) {
if(countryOptions[a].value.toLowerCase().includes("canada")) {
countryOptions[a].selected = true;
}
}
}
}
你可以嘗試countryOptions.selectedIndex = a; 代替countryOptions [a] .selected = true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.