Page 1 of 1

Change the event hooked to a themeable button

Posted: Thu Mar 26, 2026 4:32 am
by jPaul
Hi Everybody,
I have a Themeable Button on a website. The value of that button is established by a PHP variable:
Button value = "Log In" or Button Value = "Log Out".
Works fine.
So now the action to that button is dependant upon the value of $myLogValue I need to include this javascript to the
Themeable Button:

Code: Select all

var btnValue = $('myLogValue').val();
if (btnValue == 'Log In') {
	// Action for first value
	login.php;
} else {
	// Action for second value
	logout.php;
}
How can I go about inserting that code in the event tab of the Themeable Button?

Re: Change the event hooked to a themeable button

Posted: Thu Mar 26, 2026 7:02 am
by Pablo
You cannot insert completer scripts in an event, instead you will need to call function that is defined somewhere else on the page.

Re: Change the event hooked to a themeable button

Posted: Thu Mar 26, 2026 11:28 am
by jPaul
need to call function that is defined somewhere else on the page
Will you expand on this a little, please? ( I don't see anythiong like a run javascript )

Re: Change the event hooked to a themeable button

Posted: Thu Mar 26, 2026 12:15 pm
by Pablo
Step 1
Add the function that implements your logic in Page HTML or a HTML Object.
For example;
<script>
function doSomething()
{
...
}
</script>

Step 2
Set the action of the event to 'javascript'

Step 3
In 'JavaScript' input field, use doSomething();