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();

Re: Change the event hooked to a themeable button

Posted: Sat Apr 18, 2026 8:45 pm
by jPaul
How do I enter "doSomething()" in the javascript field. All I can see is a list of predefined functions. I don't know how to add my "doSomething()" script to that list?

Re: Change the event hooked to a themeable button

Posted: Sat Apr 18, 2026 11:06 pm
by BaconFries
As it is a themeableButton you will need to apply a click event as such onclick="doSomething()"
And

Code: Select all

<script>
function doSomething()
{
... <<< the dots is were your code example should go!
}
</script>

Re: Change the event hooked to a themeable button

Posted: Sun Apr 19, 2026 6:10 am
by Pablo
How do I enter "doSomething()" in the javascript field.
You can simply type the value in the input field.