I have table “project” with fields “fund_organisation” and “fund_organisation_other“. Here detail information:
- fund_organisation type = dropdown
- fund_organisastion_other = text field
- By default, fund_organisastion_other is hidden
- In fund_organisation, when i select other in dropdown value, fund_organisastion_other fill appears, and user are compulsory to fiil up the field.
Here’s a step-by-step guide:
- Open PHPRUNNER and load your project.
- Navigate to the Events section for the table where you have “project”.
- Select the appropriate event. For this scenario, use the JavaScript OnLoad event.
- Add the following code to the event:
//TO ENSURE AFTER SAVE THE HIDE AND SHOW IS FUNCTIONING
var ctrl_fund_organisation = Runner.getControl(pageid, “fund_organisation“);
pageObj.toggleItem(“integrated_edit_field10”, false );
if (ctrl_fund_organisation.getValue()==”0″) //0 is ID for Other.
{
pageObj.toggleItem(“integrated_edit_field10”, true); //This is textfield
}
//ACTION SHOW ATAU HIDE WHEN SELECT DROPDOWN
var ctrl_fund_organisation = Runner.getControl(pageid, “fund_organisation“);
ctrl_fund_organisation.on(‘Change’, function(e)
{
if (ctrl_fund_organisation.getValue()==”0″)
{
//DISPLAY FIELD
pageObj.toggleItem(“integrated_edit_field10”, true); //This is textfield
//REQUIRED FIELD
var ctrl_fund_organisation_other = Runner.getControl(pageid, ‘fund_organisation_other‘);
ctrl_fund_organisation_other.addValidation(“IsRequired”);
}
else
{
//HIDE FIELD
pageObj.toggleItem(“integrated_edit_field10”, false); //This is textfield
//AND ALSO FIELD WILL BE RESET AFTER HIDE OR NOT ACTIVE
var ctrl_fund_organisation_other = Runner.getControl(pageid, ‘fund_organisation_other‘);
ctrl_fund_organisation_other.clear();
}
});