Skip to Content
Menu
This question has been flagged
1 Reply
4968 Views

I added custom button inside a website form but after clicking it always calls website/form controller and says 'Bad Request'. How I make it call only JS function that I added without going to controller?

Avatar
Discard
Best Answer

Hi,

In .xml

<button name="my_button" type="object" string="My Button" on_click="my_js_function"/>

js:-

function my_js_function() {
// code for your JavaScript function goes here
}
// add event handler for button click event
document.getElementById('my_button').addEventListener('click', function(event) {
// call JavaScript function
my_js_function();
// prevent default action of button
event.preventDefault();
});

Regards

Avatar
Discard
Related Posts Replies Views Activity
2
May 25
9702
3
Mar 24
5324
1
Jan 21
3381
1
Jun 18
3360
0
Jan 25
1096