Page 1 of 1

Buttons?

Posted: Wed Jan 17, 2024 5:02 pm
by peters
I am still new to using this web builder, but got most of the functionality and options under by belt now.
I have still one remaining thing I just don't understand. I'll provide for you the functionality I am trying to figure out and it involves a basic button dropped on a webpage.
I have no form on the webpage just a textarea displaying some information from a record I want to delete.
I have 2 buttons, Yes to delete or No to cancel deletion. User selects No if he/she does not want to delete the record and the button is set to link to the previous webpage . . . so no problem here.
The button that is Yes is my issue. All I want to do is click the button and delete the record. I am not using submit as no form involved and all I want to run is a SQL-statement . . .
Delete FROM deliveries WHERE id = 64
I am looking at the button's onclick event and I do not see anyway to add in any custom PHP or Javascript.
Is there any way to simple run any custom script from the buttons onclick event?

Re: Buttons?

Posted: Wed Jan 17, 2024 5:07 pm
by Pablo
This is not specific to WWB, but more web programming in general.

Firstly, you will have to write a PHP script that deletes the record.
Secondly, you can to trigger the script via a link or Javascript/AJAX.

Re: Buttons?

Posted: Wed Jan 17, 2024 7:36 pm
by peters
Hi Pablo,

Yep, I was pondering at the event tab as to why one could not have an option for entering in a custom function call as currently you only have 16-17 javascript presets that you can pick from. Seemed to me this would be a good entry point to say pick a new event, select the onclick event that then allow the developer to make a call to a custom javascript function.
Just seems strange to me you have the Events tab and you have all the different events such as onclick, ondblclick, ondrag, etc.; can pick Action: javascript; but no way to enter in a custom javascript call.
Maybe a thing that would be better suited in the suggestions for the next upgrade.

I looked at a work-a-round that I just tested and it is working fine. I set the button to Link to: File. Then selected my custom Filename: that is an external php file and in it my required PHP server-side commands with embedded javascript I wanted to run. So this is kind of what I was looking at doing with the onclick event.

Pete,

Re: Buttons?

Posted: Wed Jan 17, 2024 8:42 pm
by Pablo
You can use events to call a custom JavaScript function.
You can enter any valid code, in the input field!

Image

Re: Buttons?

Posted: Wed Jan 17, 2024 11:28 pm
by peters
Ok... super that is what I wanted to verify!
Thanks