Jump to content
Sign in to follow this  
Flamengo

Subtractiong Values

Recommended Posts

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>

Share this post


Link to post
Share on other sites

The variable "txtWeight" is not initialized anywhere and there is no such thing as a "result" property on ordinary HTML DOM elements.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...