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

Thread: total

  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    total

    Ok, so sorry this code is so messy, but I have a simple(I think) question....how can I add line totals together and display a total. the line total is the quantity * price piece at the end. I am using a web sql(I know it is depracated, but that is what I am using) and I need to be able to add all the line totals to give me one "lump sum" total. does this kindof make sense as to what I want to do? I am fairly new to javascript so I am not sure how complicated or simple this may be...I could easily do in PHP....but javascript is a completely different story. any help is greatly appreciated

    Code:
    return "<form type='post' onsubmit='update"+ row.product_id +"(); return false;'><table cellpadding='0' cellspacing='0' width='100%'><tr height='10' class='bord'><td width='10%'>[<a href='javascript:void(0);'  onclick='html5rocks.webdb.deleteTodo(" + row.ID +");'>Delete</a>]</td><td width='15%'>" + row.product123 +"</td><td width='15%'>" + row.category +"</td><td width='10%'><input id='qty" + row.product_id +"' type='text' value='" + row.quantity +"' size='5' onfocus = 'getID(this)'><div style='Display:none'>" + row.quantity +"</div></td><td width='10%'><input id='discount" + row.product_id +"' type='text' value='' size='5' onfocus = 'getID(this)'/> </td><td width='30%'><input id='price" + row.product_id +"' type='text' value='" + row.price +"' size='5' onfocus = 'getID(this)'/><input id='id" + row.product_id +"' type='hidden' value='" + row.ID +"' size='5' onfocus = 'getID(this)'/><div style='Display:none'>" + row.price +"</div><input name='submit' id='submit' type='submit' value='Update' /></td><td>" + row.price * row.quantity +"</td></tr></table></form>";
    		
          }

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,480
    Thanks
    6
    Thanked 981 Times in 954 Posts
    It would help if you showed us more than that. A total of what?

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well it needs to be a total of all the price*quantities added together. I am not sure how this "return" works. In PHP it would work inside of a loop, but I am not sure whether this is a loop or what it is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Neither are we sure.

    I can't figure out what the point of the return is.

    I can't figure out why you are putting all the HTML code into JavaScript.

    It just doesn't make lots of sense, at all.

    Maybe if you showed us a live web page?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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