This topic is locked
[SOLVED]

 Probelm with getValue() in JS OnLoad event

10/11/2019 10:24:58 AM
ASPRunner.NET General questions
Pete K author

I want to hide the text field named "Honors" if it is equal to the value "<None>".
I took the following code straight out of manual and placed it in the JS onload event:

var ctrl = Runner.getControl(pageid, "Honors");
if(ctrl.getValue() == "<None>")

{

pageObj.hideField("Honors");

}


It did not work. If I just left the hideField line in with no condition, it did hide the field. So I tested the value of [size="2"]ctrl.getValue() with an alert:[/size]

alert(ctrl.getValue);


Which resulted in the following:
[size="2"]

[/size]

[size="2"]Obviously not what I was expecting. Did I do something wrong? [/size]

Pete K author 10/11/2019

Figured it out. I needed to use the HTML entities for the angle brackets. The actual value returned by getValue() was "&lt;None&gt;"
And my test failed because I forgot the parens in the getValue() function. Duh!
For any other JavaScript-challenged people out there like me, this page in the manual was a great help: https://xlinesoft.com/asprunnernet/docs/troubleshooting_javascript_errors.htm