special condition <=>

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
lramirez
Veteran Member
Posts: 46
Joined: 2019-11-01 23:23

special condition <=>

Post by lramirez » 2022-08-19 11:51

Good morning, can someone help me or give me a guide
How can I do this condition?

if the value is <= 4 , print "low" in the condition field
if the value is = 5 , print "normal" in the condition field
if the value is >= 6 , print "height" in the condition field

Attached image

Thank you

special condition
Attachments
condition.png
condition.png (12.41 KiB) Viewed 1200 times
Luis Ramirez R.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: special condition <=>

Post by D Oliveira » 2022-08-19 12:26

code note tested

tablename-dv.js -> replace table name for your tablename and put this file inside hooks directory

Code: Select all


$j(function()){


$j('#field_name').on('change', function(){

if( $j('#field_name').val() <= 4 ){

     $j('#another_field').val('low');

}else if( $j('#field_name').val() == 5 ){

     $j('#another_field').val('normal');

});



}; // end file


lramirez
Veteran Member
Posts: 46
Joined: 2019-11-01 23:23

Re: special condition <=>

Post by lramirez » 2022-08-21 01:06

Thanks...it works.

$j(function(){

$j('#bmc').on('change', function(){

if( $j('#bmc').val() <= 18.5 ){

$j('#condition').val('LOW');

}else if( $j('#bmc').val() >= 18.6 ){

$j('#condition').val('NORMAL');
}
});
})


Thanks...it works...but
Excuse my English,
I am learning to program.
I would like to make a form that gives me the result of
Body Mass Index (BMI)
field_weight
height_field
field_bmi
field_condition
can it be done in the same file tablename-dv.js ?
A guide please!
(If I write the bmi if "condition" appears, but if I generate it automatically with SQL there is no condition)

If you could guide me, thank you.
Attachments
CONDICION5.png
CONDICION5.png (6.68 KiB) Viewed 1158 times
CONDICION2.png
CONDICION2.png (6.9 KiB) Viewed 1158 times
Luis Ramirez R.

lramirez
Veteran Member
Posts: 46
Joined: 2019-11-01 23:23

Re: special condition <=>

Post by lramirez » 2022-08-27 04:05

Sorry for the translation, my language is Spanish.

in the hooks/patient.php table I added this:


function paciente_init(&$options, $memberInfo, &$args) {

if(isset($_REQUEST['SelectedID'])){
$id=makeSafe($_REQUEST['SelectedID']);

sqlvalue("UPDATE paciente set imc=ROUND(`peso` / (`altura` * `altura` )) /2.2");
}

return TRUE;
}



and in hooks/patient-dv.js I added this:
(it works but I'm not sure if that's ok) :D

$j(function(){

$j('#imc').on('change', function(){

if( $j('#imc').val() <= 18.4){

$j('#condicion').val('BAJO PESO');

}else if( $j('#imc').val() >= 18.6 && $j('#imc').val() <= 24.9 ){

$j('#condicion').val('SALUDABLE');

}else if( $j('#imc').val() >= 25.0 && $j('#imc').val() <= 29.9) {

$j('#condicion').val('SOBRE PESO');

}else if( $j('#imc').val() >= 30.0 && $j('#imc').val() <= 34.9 ){

$j('#condicion').val('OBESIDAD');

}else if( $j('#imc').val() >= 35.0 && $j('#imc').val() <= 39.9) {

$j('#condicion').val('OBESIDAD SEVERA');

}else if( $j('#imc').val() >= 40.0 ) {

$j('#condicion').val('OBESIDAD MORBIDA');
}

});
})


:?
the problem I have is that when I add the weight and height values it shows me the IMC result when saving, but it does not tell me the condition automatically, so I have to touch the IMC field with the mouse again and save again to that the condition created with a text field appears, option list.

If someone can help me to the condition that is generated automatically when the IMC is displayed.
Attachments
imc1.png
imc1.png (8.12 KiB) Viewed 1044 times
imc5.png
imc5.png (32.95 KiB) Viewed 1044 times
Luis Ramirez R.

Post Reply