Show field based on select value in select box

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
amsire2
User
Posts: 149

Show field based on select value in select box

Post 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?


arbei
User
Posts: 9719

Post by arbei »

You may use Client Side Events.


amsire2
User
Posts: 149

Post 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;

}

arbei
User
Posts: 9719

Post 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.


amsire2
User
Posts: 149

Post 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.


arbei
User
Posts: 9719

Post 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.


arbei
User
Posts: 9719

Post by arbei »

You may learn to debug your code in your browser, see Debug JavaScript.


DGarza
User
Posts: 134

Post 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();
}

Post Reply