Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    forms - add to total

    hi

    i have a dropdown menu, and i wanted to know how to add an amount to a total if that item was selected, and if another one was selected then for a total to be altered.

    if this was a shop, and then dropdown consisted of products, i want the total to change as a different product is selected.

    making the menu wasnt hard, and i tried working with javascript to edit a total but im not sure how, so if anyone can help me to learn how it would be much appreciated

    thanks
    sandeep

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps this will give you some ideas: Using Checkboxes to Update a Total
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function AddTo(obj,nme){
     obj.form[nme].value=obj.form[nme].value-(obj.last||0);
     obj.last=obj.value;
     obj.form[nme].value=obj.form[nme].value*1+obj.last*1;
    }
    
    //-->
    </script>
    
    </head>
    
    <body>
    <form>
    <select onchange="AddTo(this,'TotalIP');" >
    <option value="0" >Option 0</option>
    <option value="10" >Option 10</option>
    <option value="20" >Option 20</option>
    <option value="30" >Option 30</option>
    <option value="40" >Option 40</option>
    </select>
    <br>
    
    <select onchange="AddTo(this,'TotalIP');" >
    <option value="0" >Option 0</option>
    <option value="12" >Option 12</option>
    <option value="22" >Option 22</option>
    <option value="32" >Option 32</option>
    <option value="42" >Option 42</option>
    </select>
    <br>
    
    <input type="text" value="0" name="TotalIP" >
    </form>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #4
    New Coder
    Join Date
    Jun 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cheers thats exactly what i needed


  •  

    Posting Permissions

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