Flamengo Posted November 27, 2019 Share Posted November 27, 2019 Hi, Im trying to subtract 3 from the value If the radio button is checked. However, its not working. <script type="text/javascript"> function calcShipping() { var txtWeight, pound1, pound2, pound3, freq, notfreq, freq1; var values = " "; freq1 = 3; pound1 = 5; pound2 = 10; pound3 = 15; txWeight = document.getElementById("txtWeight").value; txWeight=parseInt(txWeight); if (txWeight < 1) {document.write("Your cost is " + pound1 + "$.") }; if (txWeight >= 1 & txWeight < 3) {document.write("Your cost is " + pound2 + "$.") }; if (txWeight >= 3 & txWeight <= 5) {document.write("Your cost is " + pound3 + "$.") }; if (document.getElementById("freq").checked = true){ document.write(" Your cost is " + (txtWeight.result - freq1) + "$."); } else if (document.getElementById("notfreq").checked){ document.write("Your cost is " + (txtWeight.value) + "$."); } } </script> Link to comment Share on other sites More sharing options...
Ingolme Posted November 28, 2019 Share Posted November 28, 2019 The variable "txtWeight" is not initialized anywhere and there is no such thing as a "result" property on ordinary HTML DOM elements. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now