There can be multiple reasons why your input consistently gives a result of 0 when using .target.innerHTML:
You might be trying to access the value of the input element using .innerHTML instead of .value. .value returns the current value of the input element, whereas .innerHTML returns the HTML content inside the element.
You might not be converting the value of the input element from a string to a number before displaying it. When you use .innerHTML to display the value of the input element, it is displayed as a string. This may cause issues when you try to perform mathematical operations with the value.
There might be some issues with the input itself, such as incorrect type or value. Make sure the input has the correct type attribute (e.g., number, text). Also, check if the value entered into the input is a valid number.
Overall, to get a better understanding of why you are consistently getting a result of 0, carefully examine your code and debug with console.log() statements to see if you are correctly accessing and manipulating the value of the input element.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-08-18 11:00:00 +0000
Seen: 20 times
Last updated: Feb 11 '23
How can the output of a loop within a function be visualized using Rshiny?
What is the process of gathering an iterator and storing it as a Result?
How can SolidJS context be utilized in an asynchronous function?
Is there a simpler way to achieve the same result in Excel rather than having a lengthy formula?
How can Excel VBA identify the row that contains the formula result of #N/A?