Using JavaScript in the onload event

Use this board for starting discussions, asking questions, and giving advice on Web programming for the IBM i platform (and predecessors.)
Roger_NALC
New User
Posts: 1
Joined: Wed Jul 20, 2016 11:42 am
First Name: Roger
Last Name: Parent
Company Name: NALC
Phone: 2026622822
Address 1: 100 Indiana Ave NW
City: Washington
State / Province: District of Columbia
Zip / Postal Code: 20001
Country: United States
Contact:

Using JavaScript in the onload event

Post 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.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Using JavaScript in the onload event

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest