Dynamically Show/hide a Control

July 30, 2007 at 12:51 pm 1 comment

The browser script Control method ‘SetProperty’ is fairly limited: it only works at all with CheckBox, ComboBox, TextBox and TextAreas, and even with these controls I’ve found behaviour to be flaky. In my experience it’s more reliable to grab a handle to the control and access the DOM properties directly.

For instance, to conditionally show or hide a control using browser script, the code looks like this:

var ctrl = thisApplet.FindActiveXControl("My Control");

if( ctrl != null )

{

  if( myFlag )

    ctrl.style.visibility="visible";// show control

  else

     ctrl.style.visibility="hidden";// hide control

}

This approach can also be used to set other display properties – like the font and colors – but you have to be a bit more careful with interactive properties: the standard HTML property disabled does not work the same as Siebel’s Enabled control property, for instance.

The best reference I’ve found to the complete set of DOM properties is on MSDN, with the advantage that everything here should be available to Siebel’s IE-only environment.

Advertisements

Entry filed under: Scripting, Siebel.

Order of Events Synchronous Wait Steps

1 Comment

  • 1. Arun  |  December 2, 2010 at 2:07 am

    Hi,

    This post is very gud but could you please let me know on which event this browser script should be written. And also if could know about the below thoughts and share it.
    To Hide –
    document.getElementById(“”).style.display=”none”;

    Show –
    document.getElementById(“”).style.display=””;

    You have to make it visible again (in formload)
    document.getElementById(“”).style.visibility=”visible”;

    Thanks,
    Arun


Feeds


%d bloggers like this: