I have a script in which the logic is working properly but only on the “Page is loaded” workflow.
Basically this script is used to compare two lists and return a value from one of them based on the idex got from a dropdown value.
// get option list
var optionList = "Search for product_options:each item's options".split(",");
// get price list
var addPriceList = "Search for product_options:each item's add_price".split(",");
// get price value from dropdown <<<HERE >>>>
var dropDownValue = document.getElementById("dropdown").value
function getPrice(string){
// format bad formatted string from bubble dropdown value.
var formattedDropdown = string.replace(/(^"|"$|\\"|\')/g, '')
// get index on optionList based on dropdown value treated.
var index = optionList.indexOf(formattedDropdown)
// return price compared with the same index of option
return addPriceList[index]
}
bubble_fn_a(getPrice(dropDownValue));
Since this dropdown has a default value, when the script “run javascript” is added to “Page is loaded” it gets this “default value” from the dropdown not making the update when I change the value from it.
Therefore, How can I make this script updates the value every time I change it from the dropdown? It seems that “run javascript” only works on “Page is loaded” statically, since I tried to place it in other workflow other than “Page is loaded”. Is that right? There is other way I can perform it? thank you.