0

What is wrong in my JavaScript program ?

When user inputs into second input box the second selection box automatically change to indian rupee code with error : https://code.sololearn.com/WGX36ZuyXKIa/# but when i changed the order of if else its started running as i want corrected code : https://code.sololearn.com/WslbM6Oj08ol/# tell me why my programming was not running as desired and why its running in second code.

29th May 2022, 2:01 PM
Abhishek Shelar
Abhishek Shelar - avatar
3 odpowiedzi
+ 2
The problem is that first if statement is assigning value to s1 or s2 when there is an change to the value i1 or i2. ex if(s1.value="RUP")... this if statement is considered to be true so it will assign "RUP" to the value of s1, instead of comparing the value of s1 to "RUP". In this case you should be using "==" or "===" To be clear all of the if and else if statements are set to assign a value instead of comparing values.
29th May 2022, 3:51 PM
ODLNT
ODLNT - avatar
+ 2
You're welcome, glad I could help
30th May 2022, 4:43 AM
ODLNT
ODLNT - avatar
+ 1
Thank You ODLNT.
29th May 2022, 5:11 PM
Abhishek Shelar
Abhishek Shelar - avatar