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?
This question has been flagged
1
Odpovědět
6221
Zobrazení
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit se| Related Posts | Odpovědi | Zobrazení | Aktivita | |
|---|---|---|---|---|
|
|
2
kvě 25
|
10966 | ||
|
|
3
bře 24
|
6685 | ||
|
Website form field conditions
Vyřešeno
|
|
1
led 21
|
4478 | |
|
|
1
čvn 18
|
4347 | ||
|
|
2
lis 25
|
677 |