Results 1 to 5 of 5

Thread: java script help to perform caculation

  1. #1
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Cool java script help to perform caculation

    Hi to all the forum members!, I created a order form using textboxes, to collect a multiline/singleline input of text however in my case, the form has to also calculate numeric values, as well as add them and give a total, so let me illustrate, txtbox1 collects singleline text(non numeric data), txtbox2(quantity) collects singleline numeric data, multiplies it by txtbox3 (price), totals that by txtbox4(subtotal). I am using Visual web developer, language c#, I have written a stored procedure to take the input from the text boxes and insert them into a database (SQL server 2005 express), so i need a javascript to calculate, tax, discount and give a true total Any help/advice would be welcomed!!

  2. #2
    Join Date
    Jan 2005
    Posts
    246
    Rep Power
    0

    Default

    i dont quite get this. You want a javascript to take data from 2 textboxes, work on it and put the answer in another textbox, use that same answer and submit to the database?
    you'd have to do something like this in the js:
    var txtb1 = document.getElementByID('<%= textbox1.ClientID %>');
    var txtb2 = document.getElementByID('<%= textbox2.ClientID %>');

    typecast this to int or double or watever...not sure if you even typecast in javascript.

    var myFinalValue = txtb1.value + txtb2.value;
    document.getElementByID('<%= textbox3.ClientID %>').value = myFinalValue;
    Last edited by Mixmasterxp; Aug 17, 2008 at 11:32 PM.

  3. #3
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    This thread was created in the wrong section.
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

  4. #4
    Join Date
    Jan 2005
    Posts
    246
    Rep Power
    0

    Default

    put that in some onChange event or watever u want when the textbox should update.

  5. #5
    Join Date
    May 2003
    Posts
    108
    Rep Power
    0

    Default

    instead of using javascript (client side), why not just do it on the server side. It is much easier that way.
    www.pixJM.com - View and upload photos/videos of what's currently happening in the streets of Jamaica.

Posting Permissions

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