This topic is locked

How to hide/show control along with its label on Add/Edit pages

1/9/2014 10:43:53 PM
PHPRunner Tips and Tricks
admin

PHPRunner manual comes with example of hiding/showing controls on Add/Edit pages based on another control value:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm
For better user experience you may want to hide field label as well. Here is the sample code. This code will work with PHPRunner 7.0 and single column Add/Edit page layout.

var ctrlCountry = Runner.getControl(pageid, 'country');



ctrlCountry.on('change', function(e){

if (this.getValue() == 'US'){

$("tr[data-fieldname='state']").show();

}else{

$("tr[data-fieldname='state']").hide();

}

});


This is it, the whole table row with state edit control will be hidden or shown based on country field selection.

A
Anapolis 3/8/2014



PHPRunner manual comes with example of hiding/showing controls on Add/Edit pages based on another control value:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm
For better user experience you may want to hide field label as well. Here is the sample code. This code will work with PHPRunner 7.0 and single column Add/Edit page layout.

var ctrlCountry = Runner.getControl(pageid, 'country');
ctrlCountry.on('change', function(e){

if (this.getValue() == 'US'){

$("tr[data-fieldname='state']").show();

}else{

$("tr[data-fieldname='state']").hide();

}

});


This is it, the whole table row with state edit control will be hidden or shown based on country field selection.


The initial state is HIDE, right?
So when the page is loaded the "state" page object, a dropdown selector of different US states, should not appear at all.
I could not get this to work correctly until I made some revisions to this example.
I have a Yes or No, Ja oder Nein, radio button that by default was checked "Ja" and the field was named "Mailout".
If the button is changed to "Nein" then the Hidden row with the date selector field named "specialmail" appears.
If the user changes their mind and decides to re Select "Ja" then the Date field below disappears again.

My code is essentially the same code as the Example but presets the HIDE state first.

var ctrlMailout = Runner.getControl(pageid, 'mailout');

var ctrlSpecialmail = Runner.getControl(pageid, 'specialmail');
$("tr[data-fieldname='specialmail']").hide();
ctrlMailout.on('change', function(e){
if (this.getValue() == 'Nein'){
$("tr[data-fieldname='specialmail']").show();
}else{
$("tr[data-fieldname='specialmail']").hide();
}
});
A
Abul 5/9/2014



The initial state is HIDE, right?
So when the page is loaded the "state" page object, a dropdown selector of different US states, should not appear at all.
I could not get this to work correctly until I made some revisions to this example.
I have a Yes or No, Ja oder Nein, radio button that by default was checked "Ja" and the field was named "Mailout".
If the button is changed to "Nein" then the Hidden row with the date selector field named "specialmail" appears.
If the user changes their mind and decides to re Select "Ja" then the Date field below disappears again.

My code is essentially the same code as the Example but presets the HIDE state first.

var ctrlMailout = Runner.getControl(pageid, 'mailout');

var ctrlSpecialmail = Runner.getControl(pageid, 'specialmail');
$("tr[data-fieldname='specialmail']").hide();
ctrlMailout.on('change', function(e){
if (this.getValue() == 'Nein'){
$("tr[data-fieldname='specialmail']").show();
}else{
$("tr[data-fieldname='specialmail']").hide();
}
});



This thread is fantastic and it works for me. However, it seems to be applicable for a single table or page. Does this work on detail page when Add/Edit Master and Detail on same page. Do you have any idea please. Thanks.