简体   繁体   中英

JavaScript: Why Won't This Work?

http://pastebin.com/hXpAf7aA

This JavaScript program I made is supposed to compare two teams based on user input. Although, all it does is run "else". Please help!

As you are comparing values and as per the code else block will be executed only when both the values are equal which as per your code will always be equal.

You have initialized the values at the time of load when the values for all the fields is empty. And when you go ahead and click on functions to compare, you are using the initialized values only.

The solution to problem is that when you click on the buttons to compare in those functions get the current values and then compare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM