Page 1 of 1

<RESOLVED> calculating an value (with some ajax?)

PostPosted: Thu Aug 06, 2009 9:31 am
by PolderBoy
Clients newest wish:

When he selects from a pulldown menu in the "new" page the next field should be filled with a number.

Let me explain: When the user adds a new office in the program, the office_nr gets filled with a number (max + 1)

Code: Select all
   function KantoorID__default()
   {
      include("conf.php");

      $con = mysql_connect($host, $user, $password);

         if (!$con)
         {
            die('Could not connect: ' . mysql_error());
         }

      mysql_select_db($name, $con);
      
      $sql = "SELECT MAX(KantoorID) AS Hoogste FROM D2D";

         $result = mysql_query($sql);
         $row = mysql_fetch_array($result);
         $terug = $row['Hoogste'] + 1;

      mysql_close($con);

      return $terug;

   }


The above works for the adding of a new office but for a new client I need the value of a select box. (officeID + followNr example: 010001: office 01 client 0001)

When he adds a new client he must first select a office and regarding this office_ID the client_nr is calculated but how do I find the value he has selected in the pulldown before he has saved?

thanks in advance,

Polderboy

PostPosted: Fri Aug 07, 2009 12:32 am
by Jean
Hi,
May be, you could find a part of your answer in this post http://xataface.com/forum/viewtopic.php?t=4352
Jean

resolved

PostPosted: Mon Aug 10, 2009 6:33 am
by PolderBoy
Thanks Jean,

I think I have it working now:

In the fields.ini I have:

[OfficeNummer]
widget:atts:onblur="ContrNr_Check();"

Which is a function in the included javascript.
In this script I use the value of the selected pulldown(OfficeNummer)
to sent to a phpfile on the server. So that I can sent back the next free number to the script and this value is used to fill the next text box.

It is so easy, now I know how....

Thanks again.

Polderboy