Javascripting Problem

Discussion in 'OT Technology' started by Chadnel25, Oct 7, 2004.

  1. Chadnel25

    Chadnel25 Member

    Joined:
    Nov 18, 2002
    Messages:
    949
    Likes Received:
    0
    Location:
    Pittsburgh PA
    i have to write a script to alert the user the total price when they click the submit button.......

    here is my script

    <script language="javascript">
    <!--
    function validateQuantity() {
    var currQuantity = document.frmOrderItem.txtOrderQuantity.value;
    if(currQuantity >= 1) {
    total = currQuantity * 39.99;
    alert("Order Total: $ ");
    }
    else{0-
    alert("Desired Quantity value must be between 1 and 100.");
    }
    }
    //-->
    </script>
     
  2. Chadnel25

    Chadnel25 Member

    Joined:
    Nov 18, 2002
    Messages:
    949
    Likes Received:
    0
    Location:
    Pittsburgh PA
    my problem is that when it alerts the user.... instead of calculating the price and displaying it in the alert, it just displays the $ sign.

    why cant i get it to calculate and show the total?

    i even tried to assign the Ordertotal so that it would read

    Ordertotal = currQuantity * 39.99;
    alert("Order Total: $Ordertotal ");
     
  3. WERUreo

    WERUreo Imua!

    Joined:
    Oct 15, 2003
    Messages:
    566
    Likes Received:
    0
    Location:
    Daytona Beach, Florida
    Even just in your original script, you don't have the alert displaying the variable value at all. You've just got
    Code:
    alert("Order total: $ ");
    You're already assigning the amount to the variable total, so just do what hsmith said.
     

Share This Page