SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating Total using Javascript

    Hi,

    I have seen on the net a few examples of input fields with values that are automatically updated when a value in the form is changed. For example, if I increase the quantity in input Qty, the input text Total is updated using the value of Qty * Unit Price.

    My question is, does Total need to be an input field, or can it be simple text? I suppose that if it had to be an input field, I could disguise the input border by setting it to 0 and color white.

    Second and last question, can anybody please direct me to a good example of such a script?

    thanks,

    DH

  2. #2
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again,

    I am having a problem with the script above. While the script uses an input field to change the quantity, I would like it to work with a select field, and with the select options. Could anyone please suggest how to modify it to make it work?

    DH

    EDIT: The input field (in the original script) the programmer uses onkeydown, onKeyUp and onkeypress. Does anybody know what are the equivalent functions if instead of <input /> I use <select><option></option></select> ?
    Last edited by dhtmlhelp; Oct 11, 2003 at 08:48.

  4. #4
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a monologue, since I can't delete this post I might as well speak up. I changed all those functions with onChange (for the select fields). It works perfectly, hope it becomes useful to other people, it is really easy to integrate with php.

    DH


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
  •