| Index
» Projekty
» phpMyEdit
» Fórum
» Automatic fill a field value after a drop down selection ? |
 |
pmozer
Založený: 02.02.2004
Príspevky: 3
Zaslal: 2004-02-23 10:43
Návrat hore
Odpovedať s citátom
|
Dear all,
Firstly, thank you very much to the team for this great piece of code and their 'open mind'...
My problem :
I have 2 tables :
- 'operator' (Fields : ID_OPERATOR, LOGIN_OPERATOR, NAME_OPERATOR)
- '_b_users' (Fields : ID_b_users, login_b_user, NAME_USER,USER_EMAIL)
I want from table 'operator' select in a drop down selection a 'login_b_user' variable and automatically fill the 'NAME_OPERATOR' field with the 'NAME_USER' value.
So, I use for 'LOGIN_OPERATOR' :
$opts['fdd']['LOGIN_OPERATOR'] = array(
'name' => 'LOGIN_OPERATOR',
'select' => 'T',
'maxlen' => 12,
'required' => true,
'sort' => true,
'values' => array(
'table' => '_b_users',
'column' => 'login_b_user'
)
);
For 'NAME_OPERATOR', may I use a default value like :
$opts['fdd']['NAME_OPERATOR'] = array(
...
'default' => $opts['fdd'][something?]
I hope that it's clear ;-)
Long life to PhpMyEdit...
Pierre.
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-02-23 12:24
Návrat hore
Odpovedať s citátom
|
if i understand right, you want to fill two field based on one dropdown box
easy answer:
why do you want to do this ? it is storing unnecessary data in your database (the name can be achieved from id)
hard answer:
this could be done by before triggers by changing user input. but the insert query is created not in standart way, so you will have a hard time (see bug report on insert query). i hope this behavior will come to an end, so i would not do this.
not too hard answer:
make after trigger that will update your record. it will change name based on the id value. but again this can fail.
|
pmozer
Založený: 02.02.2004
Príspevky: 3
Zaslal: 2004-02-26 10:54
Návrat hore
Odpovedať s citátom
|
| michal Napísal: |
if i understand right, you want to fill two field based on one dropdown box
easy answer:
why do you want to do this ? it is storing unnecessary data in your database (the name can be achieved from id)
hard answer:
this could be done by before triggers by changing user input. but the insert query is created not in standart way, so you will have a hard time (see bug report on insert query). i hope this behavior will come to an end, so i would not do this.
not too hard answer:
make after trigger that will update your record. it will change name based on the id value. but again this can fail. |
Dear, Michal,
Thank you for your answer.
In fact, I want to join 3 differents tables.
Like it seems impossible, I thought it could be a solution to generate a new table (of course with duplicate data...)
Pierre.
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-02-27 00:02
Návrat hore
Odpovedať s citátom
|
you can join three tables, you can even join three times the same table :-)
btw you don't need to have both 'login' and 'name'. due to advantages of sql, you can insert just the id, and display both name and login (even though they are not in the table). this would be joining the same table twice (once for the foreign_id field, and once for a virtual field generated by sql)
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|