Compute and display data on the same page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shafe25
    New Member
    • Jan 2007
    • 1

    Compute and display data on the same page

    well,
    when user inputs the data, i should be able to fetch the data from the database and do some numerical computaions and display the result on the same page before i submit the data to the php script,

    the php script takes all the posted data and dump it into the database,


    how to achieve this

    me using
    PHP 5.0/MySQL 4.0
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What code do you have so far?

    This should be posted in the PHP forum, but don't double post. A moderator will probably move it soon.

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      Indeed, we will. Moving this thread...

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2432

        #4
        Look into the use of Javascript to process data on the client side, or if you really want to get creative, AJAX.
        niheel @ bytes

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Looks indeed like the perfect problem to tackle with an Ajax solution. That way you can, after the user has inputted some field(s), go to the server database, get the data and display it on the screen. All without screen refreshes.

          But, as acoder put to you in an earlier post: "What code do you have so far?". Show it and we will see where we can assist you.

          Ronald :cool:

          Comment

          • mainul
            New Member
            • Sep 2006
            • 51

            #6
            Hi
            you can use the following code for a running total. customize it according to ur requirements.

            [HTML]
            <html>
            <head>
            <script>
            function getTotalBurn()
            {
            f = document.form1;
            superficial = parseFloat(f.a. value) + parseFloat(f.b. value)
            f.c.value = superficial.toF ixed(2)
            }
            </script>
            </head>
            <body>

            <form id="form1" name="form1" method="post" action="" onkeyup="getTot alBurn()">
            <p>
            1st Number
            <input type="text" name="a" size="10" />
            </p>
            <p>
            2nd Number
            <input type="text" name="b" size="10" />
            </p>
            <p>
            Total
            <input type="text" name="c" value="0" size="10" />
            </p>
            </form>
            </body>
            </html>
            [/HTML]

            Comment

            Working...