Function Not Returning In Javascript
Solution 1:
The value property is only available on user input elements, not <h3>. And the change event is only triggered when you change the value of an input element, it doesn't apply to <h3>.
You can use textContent to get the string in an <h3> element. And if you want the action to happen when you click on it, use onclick. So they should be like this:
<h3 id="taxes" onclick="taxesrepas(this.textContent)">taxes:</h3>
Also, in the function, you should move the calculations that use taxer and pricer to after the switch statement that sets those variables.
Solution 2:
The problem is that you are trying to use h3 tags like they are input tags.
the onchange event only fires for form elements like <input>, <textarea>, or <select>. Similarly, an <h3> does nat have a value, because that is also a property of form elements.
Solution 3:
Remove the onChange from your h2 tags as they don't have onchange events.
Put a button instead and use onclick() to call your function, get your h1 values by using getElementById(id) in your function.
<buttononclick="taxesrepas()">Other way, I see you are trying to get option value.
Use select instead and check the values in your switch case.
Post a Comment for "Function Not Returning In Javascript"