I have zero knowledge of coding. I want to know how to use code to total my 2 dropdowns as shown in my picture. Any help is greatly appreciated.
Hi,
Firs of all, some coding knowledge is required in order to use wix-Code.
I suggest you to read about JS, starting with variables events and conditions.
Second, reference to the issue, you can add an onChange() event function to your both dropdown , and in each one add a condition that check if there is a value at the second dropdown, if true- update the total .
At my example the total text’s id is “total” ,
dropdown 1 his id is “dropdown1” .
dropdown 1 his id is “dropdown2”.
Here you can read about element’s event (the export functions) and ID.
Here you can read more about onChange() event.
export function dropdown1_change(event){
{
if($w('#dropdown2').value !== "" ){ //Means the user chose price in both dropdown
$w('#total').text= $w('#dropdown1').value+ $w('#dropdown2').value;
}
}
export function dropdown2_change(event) {
if($w('#dropdown1').value !== "" ){//Means the user chose price in both dropdown
$w('#total').text= $w('#dropdown1').value+ $w('#dropdown2').value;
}
}
As a result, each time the user choose an option, the total text will be update if in both dropdown there is a value.
Best of luck!
Sapir,