This topic is locked

Hiding a button control

10/8/2010 9:24:19 PM
PHPRunner General questions
K
karmacomposer author

I need to hide a button if certain things apply. Here is the code I came up with:
var ctrlGID = Runner.getControl(pageid, 'GroupID');

var ctrlBtn = Runner.getControl(pageid, 'PLACED');
ctrlGID.on('change', function(e){

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

ctrlBtn.hide();

}else{

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

ctrlBtn.hide();

}}

});
Now, I am not sure what the button control syntax is (that is the PLACED above). In this case, if the GroupID is either 'Recruiters' or 'Employers', I want the button marked PLACED to hide.
Any help is appreciated.
Mike

Sergey Kornilov admin 10/10/2010

Javascript API can be only applied to core PHPRunner form controls like text fields, dropdown boxes etc.'
To show hide a button you need to use pure Javascript.

Check this article for example:

http://www.coderanch.com/t/121579/HTML-JavaScript/hide-button-javascript

K
karmacomposer author 10/10/2010

document.getElementById('x').style.visibility='hidden'; // hide

document.getElementById('x').style.visibility='visible'; // show
Sounds logical. My only two questions are:
(1) where the line states, getElementById('x')
'x' is the button, but how do I find out the elementID of it?
(2) where do I place this code in the form? What event area does it go?
Mike

J
Jane 10/13/2010

Mike,
you need to add ID for your button manually (id=customvalue) and then use getElementById('customvalue') to access this button.

Place your code in the JavaScript onload event on the Events tab.