I'm trying to set values depending on the chosen variable of lightning-combobox so i created the following javascript
get timing() {
return [
{ label: 'Weekly', value:'weely' },
{ label: 'Monthly', value:'monthly'},
{ label: 'Code',value:'code' },
];
}
handleMonthChange(event){
this.month=event.target.value;
}
handleDoWChange(event){
this.DoW=event.target.value;
}
handleTimingChange(){
if (this.template.querySelector('timing').value="weekly"){
this.minute='0';
this.hour='0';
this.DoM='*';
}
else if(this.template.querySelector('timing').value="monthly"){
this.minute='0';
this.hour='0';
this.DoM='1';
this.month='*';
this.DoW='* ';
}
else{
this.minute='0';
this.hour='0';
this.DoM='1';
this.DoW='1';
this.month='1';
}
}
All values are already tracked. And the function that are not mentioned here for handling changes also work. The only I am having is with these functions but i can't detect where i did the error.
Edit: The page is functioning normally but when i select anything from the combobox for example – code, weekly or monthly – I get an alert that says error and with a text field to explain how i got the error
Best Answer
if condition should be a comparison.
It should be === instead of=.
Note: = is for assignment, == is for comparison without datatype comparison ("89"==89) and === is for comparison with datatype comparison("89"!=89).
Important: Install extensions for LWC in vs-code (eslint, lwc-extensions etc). With these extensions you would have known about this problem immediately.