#1
by
Bhagya
(edited )
Hi all,
I want to count the number of button clicks for a custom back button created using tabs. I used the following code for the button but does not work (button click data is not sent to the server):
<button type="button" onclick="liveSend('clicked-button')" class="btn-tab" data-offset="-1">Back</button>
When trying to debug, I found out that replacing with the following code (for a simpler submit button) works, so the rest of the code must be fine.
<button name="button" onclick="liveSend('clicked-button')">Back</button>
Am I doing something wrong? Is there a way to capture the number of clicks of a back button with tabs?
Thank you!
Bhagya
#2
by
Chris_oTree
That onclick= you wrote looks OK but it gets overwritten by this JavaScript code that runs when the page loads:
for (let btn of document.getElementsByClassName('btn-tab')) {
btn.onclick = function () {
activeTab += parseInt(btn.dataset.offset);
showCurrentTabOnly();
}
}
The solution is to add your line of code in there:
for (let btn of document.getElementsByClassName('btn-tab')) {
btn.onclick = function () {
activeTab += parseInt(btn.dataset.offset);
showCurrentTabOnly();
liveSend('clicked-button');
}
}
#3
by
Bhagya
Yes, that worked! Thank you Chris.