Issue with onload event
-
- Profound User
- Posts: 20
- Joined: Fri Jul 13, 2012 3:25 pm
- First Name: Doug
- Last Name: Lindahl
- Company Name: Anda Pharmaceuticals
- Phone: 954-217-4195
- Address 1: 2915 Weston Rd
- City: Weston
- State / Province: Florida
- Zip / Postal Code: 33331
- Country: United States
- Contact:
Issue with onload event
I have a mobile screen that we run in the ProfoundUI app. I have a switch widget on the screen that toggles a simple Javascript calculator on and off. When the user initially goes into the screen, I want the switch off which hides the calculator. So I have an onload event in the record format to pui.click the switch (turning it off). This worked until we upgraded ProfoundUI to the newest release. Now the screen locks up as if it's in an endless loop. My suspicion is that pui.click on the switch is causing the record format to reload which fires the onload event again. Am I right about this? Is there a solution that will give me a default value of 'off' for my switch? I've tried several things with no luck. Thanks
- Emily
- Profound Logic Staff Member
- Posts: 89
- Joined: Tue Jun 21, 2016 8:30 am
- First Name: Emily
- Last Name: Seage
- Company Name: Profound Logic
- Contact:
Re: Issue with onload event
Hi Doug,
The best way to set/change the value of an on/off switch would be to bind the 'value' property of the switch to a field and then set the value of that field in your RPG program or by using JavaScript.
For example, here's a typical setup for an on/off switch:
Notice this switch has the 'value' property bound to a field named switchVal. This field is defined like so:
If you wanted to change the switch in this case, you would simply set switchVal to Y or N (depending on how you're wanting the switch to appear).
This can be done in your RPG program with some standard RPG code, or you could use something like the pui.set() API that we offer to do this in JavaScript: https://docs.profoundlogic.com/x/HIAFAQ.
We hope that this helps!
The best way to set/change the value of an on/off switch would be to bind the 'value' property of the switch to a field and then set the value of that field in your RPG program or by using JavaScript.
For example, here's a typical setup for an on/off switch:
Notice this switch has the 'value' property bound to a field named switchVal. This field is defined like so:
If you wanted to change the switch in this case, you would simply set switchVal to Y or N (depending on how you're wanting the switch to appear).
This can be done in your RPG program with some standard RPG code, or you could use something like the pui.set() API that we offer to do this in JavaScript: https://docs.profoundlogic.com/x/HIAFAQ.
We hope that this helps!
Emily Seage
Support Team Lead
Support Team Lead
-
- Profound User
- Posts: 20
- Joined: Fri Jul 13, 2012 3:25 pm
- First Name: Doug
- Last Name: Lindahl
- Company Name: Anda Pharmaceuticals
- Phone: 954-217-4195
- Address 1: 2915 Weston Rd
- City: Weston
- State / Province: Florida
- Zip / Postal Code: 33331
- Country: United States
- Contact:
Re: Issue with onload event
Thanks Emily. I was able to solve it with the applyProperty API in the onload event.
Like this: applyProperty("swCalc","value","off");
Like this: applyProperty("swCalc","value","off");
-
- New User
- Posts: 1
- Joined: Tue Aug 30, 2022 3:31 am
- First Name: Nora
- Last Name: davis
- Company Name: clicker counter
- Phone: 4321567890
- Address 1: usa
- Address 2: usa
- City: usa
- State / Province: Virginia
- Zip / Postal Code: 55000
- Country: United States
- Location: United States
- Contact:
Re: Issue with onload event
You can try use in javascript: window.onload = function() { alert("let's go!"); } Its a good practice separate javascript of html.The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part o clicker counter the body, so the onload event doesn't apply there. Save this answer.n HTML, the onload attribute is generally used with the <body> element to execute a script once the content (including CSS files, images, scripts, etc.) of the webpage is completely loaded. It is not necessary to use it only with <body> tag, as it can be used with other HTML elements.onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.). However, it can be used on other elements as well (see "Supported HTML tags" below
Who is online
Users browsing this forum: No registered users and 3 guests