Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
The title of you post "Button to Fire IOL Script" suggests you may be misunderstanding what the IOL Technique does. The purpose of the IOL Technique is to inject user supplied JavaScript (saved in a code page) into a {new, view, edit, report or grid edit} page for the purpose of enhancing the behavior of the page. The injection is done when the page first loads and the code that is injected immediately executes without any user interaction. When using the IOL Technique there may or may not be buttons involved - it depends completely on what the purpose of the script is.
Now if you want a button the most convenient way to introduce it is by tacking it on to the image onload field as follows:
This will result in the following HTML being spliced into the page:
<td>
<img qbu="module" src="/i/clear2x2.gif" onload="if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=moduleTable1.js&rand='+new Date().getTime())};">
<a class="QBU_Button Vibrant Success" data-rid="1" data-name="Dan" data-payment="100">Button</a>
</td>
The first part of this HTML is the standard IOL Technique script injection. The second part of this HTML is a button with Vibrant Success class and three data attributes with values reflecting the values of three fields, [Record ID#], [Name] and [Payment]. In the code page moduleTable1.js we listen for a click on the button with class QBU_Button and when it occurs extract the three data attributes and store them in variables rid, name and payment,
So the Button does not "FIre the IOL Script." Rather the script listens for the button being clicked.
Here is a demo:
IOL With Button ~ Table 1 Dashboard
https://haversineconsulting.quickbase.com/db/bntfq3y4z?a=td
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=671
Now if you want a button the most convenient way to introduce it is by tacking it on to the image onload field as follows:
[iol] & "moduleTable1.js" & [/iol]
&
"<a class='QBU_Button Vibrant Success' " &
" data-rid='" & [Record ID#] & "'" &
" data-name='" & [Name] & "'" &
" data-payment='" & [Payment] & "'" &
">Button</a>"
This will result in the following HTML being spliced into the page:
<td>
<img qbu="module" src="/i/clear2x2.gif" onload="if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=moduleTable1.js&rand='+new Date().getTime())};">
<a class="QBU_Button Vibrant Success" data-rid="1" data-name="Dan" data-payment="100">Button</a>
</td>
The first part of this HTML is the standard IOL Technique script injection. The second part of this HTML is a button with Vibrant Success class and three data attributes with values reflecting the values of three fields, [Record ID#], [Name] and [Payment]. In the code page moduleTable1.js we listen for a click on the button with class QBU_Button and when it occurs extract the three data attributes and store them in variables rid, name and payment,
$("a.QBU_Button").on("click", function(event) {
var rid = this.dataset.rid;
var name = this.dataset.name;
var payment = this.dataset.payment;
var message = 'rid=${rid}\nname=${name}\npayment=${payment}';
alert(message);
});
So the Button does not "FIre the IOL Script." Rather the script listens for the button being clicked.
Here is a demo:
IOL With Button ~ Table 1 Dashboard
https://haversineconsulting.quickbase.com/db/bntfq3y4z?a=td
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=671
- TylerParker7 years agoQrew Assistant CaptainMakes much more sense now