This topic is locked
[SOLVED]

 Button to fill ID field

9/29/2011 9:12:00 PM
PHPRunner General questions
G
giorgiots author

Dear All,
what I'm trying to do is create a button that "reads" the maximum id stored in a table, add 1 and then fill the id field on my add page (the button placed on the same page e41_new_add.php).
The code I use in the button properties is:

(Server)

global $conn;

$str = "select max(id) as max_id from documents";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$next = $data["max_ID"]+1;
(Client after)

document.forms.editform1.value_id_1.value = $next;
every time i press the button the browser just freezes. Any ideas?
Regards

Giorgio

Sergey Kornilov admin 9/29/2011

Three suggestions.

  1. Make sure field name case matches: max_id vs max_ID
  2. Check the manual in regards to passing data from server side to the client side

    http://xlinesoft.com/phprunner/docs/inserting_button.htm
    server:

    $result["next"] = $data["max_id"]+1;;
    client:

    alert(result["next"]);
  3. Use Javascript API to assign values to edit controls:

    http://xlinesoft.com/phprunner/docs/ctrl_setvalue.htm

G
giorgiots author 9/30/2011

Thanks for the pointers!