Question: Any ideas how to NOT trigger the confirmOption function on page load, and only trigger it when the button is clicked?
So in my html body i have:
<Body>
<a href="#" id="btn_YES" onclick="<%="send('YES','" + rm.getAction ("YES") + "'); return (false);"%>" class="actionBtn"><span><span>Yes</span></span></a> 
<a href="#" id="btn_NO" onclick="<%="send('NO','" + rm.getAction ("NO") + "'); return (false);"%>" class="actionBtn"><span><span>No</span></span></a> 
</Body>
Javascript functions that have been working fine:
function send(button, url) {
if (opener.document && opener.document.forms[0] && (opener.document.forms[0].elements['sessionToken'] || opener.document.forms[0].elements['screenID']))
{
opener.answer(button, url);
window.close();
} else {
return false;
}
}
getAction and confirmOption(String option) are declared in java. If confirmOption is evaluated, it will output in the console YES or NO
function setConfirm(userSelection){
if(userSelection="YES") result = "<%=mb.confirmOption("YES")%>";
if(userSelection="NO") result = "<%=mb.confirmOption("NO")%>";
}
When i load the page, why does it print in my console:
YES
NO
, even before i clicked on the button? My breakpoint on java was triggered, so i can see that the method was being evaluated on page load – when it shouldn’t because it should be triggered when the button is clicked.
When i clicked on the button, my breakpoint was NOT triggered and i was sent to the relevant page.
Any ideas how to NOT trigger the confirmOption function on page load, and only trigger it when the button is clicked?
they wont be evaluated onload. They will get evaluated as soon as browser finds them during loading although you can defer evaluation and in the above can you are actually calling the function remove quotes