SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast AnalogPanda's Avatar
    Join Date
    Jun 2006
    Location
    sacramento, ca, usa
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calculating 2+ form field inputs on the fly

    Hi all,
    I'm working on a financial form that is filled out and then a pdf is outputted (via php).

    I'm an xhtml/css and php guy but new to javascript - I'm sure there's got to be a way to do the following with js...

    I've got a section for "project costs" with 4 fields (numeric is expected). I'd like to add a 5th field "Total Project Cost" that adds all the inputs of the first 4 fields on the fly as they are typed (or at least, after focus changes).

    Also I'd like to have a field which defaults to "10" and a drop down with 3 items that will either add 0, 5 or 10 to the field which defaults to 10.

    Can anyone recommend a script or js library that can handle these "on the fly" calculations? I appreciate the help - Thank you!

  2. #2
    SitePoint Enthusiast AnalogPanda's Avatar
    Join Date
    Jun 2006
    Location
    sacramento, ca, usa
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bump

    just thought I'd try again. I had other things to attend to, but now I'm looking into this again


    I've managed to use code from this article:
    http://www.htmlgoodies.com/beyond/we...le.php/3487841


    Specifically, the example here:
    http://www.htmlgoodies.com/legacy/be...withcotf3.html

    I managed to edit it down to all I really need (no multiplication required):
    http://aloestudios.com/sandbox/js/onthefly.html

    It works just fine for my needs, and I could leave it at that... But I'm wondering how this might be done in an unobtrusive (and perhaps more flexible) way. (I'm just learning JS, and I'd like to make sure I learn it and implement it unobtrusively as much as I can)

    Any help, suggestions, links, demos, etc would be greatly appreciated

    thank you
    Last edited by AnalogPanda; May 15, 2007 at 10:37. Reason: add more info, sample links


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
  •