This topic is locked
[SOLVED]

 Dynamic Add page

11/28/2013 9:09:42 AM
PHPRunner General questions
S
sickacid author

Hi! I have 2 table one with characteristics of the goods and another with orders.
So, for example
GOODS TABLE

id 01

desc blablabla

flag1 1 (charateristics of owner)

flag2 0 (charateristics of color)

flag3 1 (charateristics of weight)
ORDERS TABLE

id 002102

id_goods 01

owner by flag1

color by flag2

weight by flag3
In orders add page, I want to do a dropdown with goods, when I select one goods, the field owner-color-weight must be available or not by the flag in the another table.

How can i do this?

S
sickacid author 11/30/2013

Is possible to do an array of Goods table maybe in Beforedisplay?

Something like this array:'id,flag1,flag2,flag3' and with 'on.click' events compare the id_value of dropdown with id of array and get the value of flag1,2,3 ?

Sergey Kornilov admin 11/30/2013

I guess you can add your code to BeforeDisplay event, run your SQL queries there and then display or hide fields based on results.
Here are some examples:

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

S
sickacid author 12/2/2013

I think is not right, I need to get de vaule when I click on dropdown. Maybe can I do an mysql array in beforedisplay? and in JS get the value of field with on click event and set enable or disable some field by the value in array?
I don't know this is the right code
before display:

global $conn;

$sql = "SELECT * from anagraficaattrezzature where destinazioneuso=1";

$rs = CustomQuery($sql);

$dataarticle = db_fetch_array($rs);

$pageObject->setProxyValue("ID", $dataarticle["id"]);

$pageObject->setProxyValue("FLAG1", $dataarticle["revisionabile"]);

$pageObject->setProxyValue("FLAG2", $dataarticle["codice_segreto"]);

$pageObject->setProxyValue("FLAG3", $dataarticle["NumerioSeriale"]);
JS

var F1 = Runner.getControl(pageid, 'DataAssunzione');

var F2 = Runner.getControl(pageid, 'Datalicenziamento');

var F3 = Runner.getControl(pageid, 'CodiceFiscale');

var TD = Runner.getControl(pageid, 'Tipo_dispositivo');

TD.on('change', function(e){
//how can i do the cicle to associate the ID with TD ?
if (F1.getValue() == 1){

F1.setEnabled(); //abilita il campo data licenziamento

}

ELSE{

F1.setDisabled(); //abilita il campo data licenziamento

}

if (F2.getValue() == 1){

F2.setEnabled(); //abilita il campo data licenziamento

}

ELSE{

F2.setDisabled(); //abilita il campo data licenziamento

}

if (F3.getValue() == 1){

F3.setEnabled(); //abilita il campo data licenziamento

}

ELSE{

F3.setDisabled(); //abilita il campo data licenziamento

}
});



I guess you can add your code to BeforeDisplay event, run your SQL queries there and then display or hide fields based on results.
Here are some examples:

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