SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: onkeypress

Hybrid View

  1. #1
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onkeypress

    hi, i'm doing a shopping cart where by when user add a product in cart, it will show the qty, item name, and price.

    i want to use javascript to do it in a way tat when i change the qty, the price will change also.

    for eg, i type 2 in the text field of the qty, then my price will change to original price * 3.

    i keep getting error with the javacript below. hope can get help here.

    this is the javascript:
    Code:
    <script language="JavaScript">
    <!--
    function changevalue()
    {	
    
    orivalue = document.form.our_price.value;
    qtyvalue = document.form.qty.value;
    	
    newvalue = orivalue * qtyvalue;
    document.form.amount.value = newvalue;
    	
    //-->
    }
    </script>
    and my text fields are like below..(part of my codes)
    PHP Code:
    echo "<form method=post action=user_cart.php name=form>";
    echo 
    "<input type=hidden name=our_price value=$our_price>\n";
    echo 
    "<tr><td width=5% align=center><input type=text name=qty value=\"$qty\" size=2 class=ft1 onKeyPress=\"changevalue()\"></td>";
    echo 
    "<td width=15% align=center><input type=text name=amount value=\"$amount\" class=ft1></td>"
    pls help me...thanks.

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What line of the function is the error on?

    If your debugger doesn't tell you then just put an alert in and move it around to find out where the error line is.

    Flalwess
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •