You can show the dropdown list of US states if US was selected in the Country list; hide it otherwise. Use the following code in JavaScript OnLoad event on Add/Edit pages in standalone and popup mode.
var ctrlCountry = Runner.getControl( pageid, "country" );
ctrlCountry.on("change", (e) => {
if (ctrlCountry.getValue()== 'US' )
{
pageObj.showField("state");
} else {
pageObj.hideField( "state" );
}
});
In case of Inline Add or Inline Edit mode use the following approach:
var ctrlCountry = Runner.getControl( pageid, "country" );
var ctrlState = Runner.getControl( pageid, "state" );
ctrlCountry.on("change", (e) => {
if (ctrlCountry.getValue()== 'US' )
{
ctrlState.show();
} else {
ctrlState.hide();
}
});
See also:
•JavaScript API: Control object > getControl()
•JavaScript API: Control object > getValue()
•JavaScript API: Control object > on()
•JavaScript API: Control object > show()
•JavaScript API: Control object > hide()
•JavaScript API: RunnerPage object > showField()
•JavaScript API: RunnerPage object > hideField()
•JavaScript API: RunnerPage object