This topic is locked

Hide Row or Column (field) based on dropdown value

5/21/2011 8:07:55 PM
PHPRunner Tips and Tricks
R
roadyx author
  1. Hide the entire row = uncomment acoderow.style.display
  2. Hide the field = uncomment ctrlAcode.xxxx
    on HTML editor view:

    On the row you want to hide

    Example: {BEGIN acode_fieldblock}<TRid=acoderow>
    Javascript snippet:
    // dropdown control

    var ctrlMrchntid = Runner.getControl(pageid, 'mrchntid');

    // target field to appear/disappear

    var ctrlAcode = Runner.getControl(pageid, 'acode');

    //target row to appear / disappear

    var acoderow = document.getElementById("acoderow");
    ctrlMrchntid.on('change', function(e){

    if (this.getValue() == 'TESTVAL')

    {

    // choose whether you want field or entire row

    //ctrlAcode.show();

    acoderow.style.display = '';

    }else{

    // choose whether you want field or entire row

    //ctrlAcode.hide();

    acoderow.style.display = 'none'; }
    }

    );

501373 5/24/2011

what does this do?

C
chrisclements 8/21/2011

This code will allow you to hide a field on an add or edit page that you only want to show up if the user make a choice in another field that would require this field to be filled out by the user. Here is my version of this code. Hope it helps...
My code for Add Page
on HTML editor view:

The row I want to hide
-------Start Code
{BEGIN message2_fieldblock}<TR id=message2row>
----- end Code
On the Add Page - Javascript onload event
--- Start Code
var ctrlLong_text = Runner.getControl(pageid, 'long_text');

var ctrlMessage2 = Runner.getControl(pageid, 'message2');

var message2row = document.getElementById("message2row");
ctrlMessage2.hide();

message2row.style.display = 'none';
ctrlLong_text.on('change', function(e){
if (this.getValue() == '1'){
ctrlMessage2.show();

message2row.style.display = '';
}else{
ctrlMessage2.hide();

message2row.style.display = 'none';
}
});
---- End Code

C
choanhemnhe 12/22/2011

Thank Chris C and thank roadyx <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=63210&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />