Page 1 of 1

Using JavaScript in the onload event

Posted: Fri Jul 13, 2018 12:20 pm
by Roger_NALC
I have the following code embedded in the onload event in a mobile app:

var varMbid = localStorage.getItem("member");
document.getElementById("##mbid").innerHTML = varMbid;

It retrieves the member id (which is stored in the localStorage on the cell phone) correctly to my bound field (when it is an "output field"), but if I change the bound field to a "textbox", it does not populate the bound field. I'm sure it has something to do with the way the record format is initialized but I've tried turning off the "initialize record" and "put overrides" but nothing seems to work.

Re: Using JavaScript in the onload event

Posted: Fri Jul 13, 2018 12:54 pm
by Scott Klement
There is more to Profound UI widgets than just the HTML elements that you see on the screen. There is a fair amount of JavaScript code that runs behind them. Therefore, we do not recommend using the browser's DOM methods to update elements as you're doing... it doesn't interact with our code, so we can't handle things properly.

Instead, use Profound UI's JavaScript API to modify the textbox, like this:

Code: Select all

var varMbid = localStorage.getItem("member");
pui.set("##mbid", varMbid);
There is a lot of information about JavaScript coding for Profound UI under the sub-pages of the following documentation:
http://www.profoundlogic.com/docs/displ ... rofound+UI