Page 1 of 1

special condition <=>

Posted: 2022-08-19 11:51
by lramirez
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

Re: special condition <=>

Posted: 2022-08-19 12:26
by D Oliveira
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


Re: special condition <=>

Posted: 2022-08-21 01:06
by lramirez
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.

Re: special condition <=>

Posted: 2022-08-27 04:05
by lramirez
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.