Page 1 of 1
Show field based on select value in select box
Posted: Wed Jul 03, 2024 11:10 pm
by amsire2
Hi
Can anyone help me in this situation.
I have a table call Diagnose and this table consist of following fields
a. DiagnoseID
b. DiagnoseCategory
c. PresentingComplaint
d. Examination
e. BloodPressure
all the fields from c to d is visible false in add action.
If i select the DiagnoseCategory = General then I want PresentingComplaint, Examination, and BloodPressureto be visible true.
How can I do that?
Re: Show field based on select value in select box
Posted: Thu Jul 04, 2024 9:11 am
by arbei
Re: Show field based on select value in select box
Posted: Thu Jul 04, 2024 11:55 am
by amsire2
Can you show me the code?
My code is like this but nothing happen
if ($this->Diagnose_Category->CurrentValue == "General") {
$this->Presenting_Complaint->Visible = true;
}
Re: Show field based on select value in select box
Posted: Thu Jul 04, 2024 3:05 pm
by arbei
Client side events is JavaScript, you should read the link above and follow the examples and try. You may post your code for discussion.
Re: Show field based on select value in select box
Posted: Thu Jul 04, 2024 3:40 pm
by amsire2
{ // keys = event types, values = handler functions
"change": function(e) {
if (this.value == "GP: General Template") {
$(this).fields("Presenting_Complaint").visible(true);
} else {
$(this).fields("Presenting_Complaint").visible(false);
}
}
}
I do this code in Client Script - Edit Page but still did not work.
Re: Show field based on select value in select box
Posted: Thu Jul 04, 2024 8:48 pm
by arbei
You use this.value
, it only works for text box. What is the Edit Tag of the field? If not TEXT, you better use $(this).value()
. Also use console.log($(this).value());
to check the value in your F12 -> Console panel in browser.
Re: Show field based on select value in select box
Posted: Fri Jul 05, 2024 9:31 am
by arbei
You may learn to debug your code in your browser, see Debug JavaScript.
Re: Show field based on select value in select box
Posted: Thu Jul 11, 2024 2:06 am
by DGarza
Simple, you can use Jquery to do that, you need to inspect the browser page to see somes ID's from your select and inputs
Go to Server Event from you page and go to Client Script->Table-Specific->Add/Copy Page->Startup Script
$('#r_PresentingComplaint').hide();
$('#r_Examination').hide();
$('#r_BloodPressure').hide();
if($('#SelectID').val() == 1){ //1 example
$('#r_PresentingComplaint').show();
$('#r_Examination').show();
$('#r_BloodPressure').show();
}