This topic is locked

JS on load

11/27/2012 11:18:23 PM
PHPRunner General questions
K
krot author

I have three fields
Field-A is read only

Field-B is radio button

Field-C is read only
I need js script to work the following way:
If Field-B value = "X" then Value in Field-C will show the same value as in Fiels-A.

C
cgphp 11/28/2012
var ctrlFieldA = Runner.getControl(pageid, 'Field-A');

var ctrlFieldB = Runner.getControl(pageid, 'Field-B');

var ctrlFieldC = Runner.getControl(pageid, 'Field-C');
ctrlFieldB.on('change', function(e){

var thisVal = this.getValue();

if(thisVal == 'X')

{

ctrlFieldC.setValue(ctrlFieldA.getValue());

}

else

{

ctrlFieldC.setValue("");

}

});
K
krot author 11/29/2012

Thank you Cristian,
It works, but for some reason it doesn't work in google chrome unless I change the else part to ctrlFieldC.setValue(ctrlFieldA.getValue());
Any idea why?


var ctrlFieldA = Runner.getControl(pageid, 'Field-A');

var ctrlFieldB = Runner.getControl(pageid, 'Field-B');

var ctrlFieldC = Runner.getControl(pageid, 'Field-C');
ctrlFieldB.on('change', function(e){

var thisVal = this.getValue();

if(thisVal == 'X')

{

ctrlFieldC.setValue(ctrlFieldA.getValue());

}

else

{

ctrlFieldC.setValue("");

}

});