Skip Navigation

[Resolved] Onclick javascript action on dynamic button

This thread is resolved. Here is a description of the problem and solution.

Problem:

I need to have inline onclick javascript action on button.

Solution:

You can setup the button HTML codes manually, for example:

https://toolset.com/forums/topic/onclick-javascript-action-on-dynamic-button/#post-2045455

Relevant Documentation:

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 3 voices.

Last updated by zbyszekZ 3 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2032487
Zrzut ekranu 2021-04-25 o 20.43.00.png

Tell us what you are trying to do?
I need to have inline onclick javascript action on button.

Is there any documentation that you are following?
no

Is there a similar example that we can see?
yes, on current site of my client
look at screenshot, there is way how to work it on BeTheme visual builder

What is the link to your site?
hidden link

#2032873

Hello,

I have checked the URL you mentioned above, I don't see any button in the content area.

It seems you are asking for custom selector for button in JS codes, I suggest you follow jQuery document to setup the JS codes:
hidden link

#2034663
button.png

Hi Luo,
I really tried to use your advice and find any solution for my problem.
But it's a pity but I'm not programmer.
Actually it's a main reason that I love so much Toolset 😉
I need to recreate button which on BeTheme looks like this in my screenshot.
But on Toolset button I haven't possibilities to add "On click code" script.
Could you help me how to do it?

Thanks a lot in advance.

Best regards!
Zbyszek Z.

#2034849

Please provide your website credentials in below private message box, I need to test and debug it in a live website, thanks

#2036279

I assume we are talking about the this content template "Szablon dla Pakiety":
hidden link

I have tried these in your website:
1) Copy the HTML codes of button "REZERWUJ ONLINE" from URL:
hidden link

2) Paste above HTML codes into content template "Szablon dla Pakiety" as a shortcode block:
hidden link
just below the button block

3) Test it in front-end:
hidden link
It works fine.

It is just a demo for your reference, you need to style the button with custom CSS codes as what you want.

#2038719

Hi Luo,
Thanks a lot for your involvement.
You solution is almost good.
In this way I have the exactly same button for every of post with content template "Szablon dla Pakiety".
But in every Pakiet I should have different number of ID (eg. OfferID:270392).
And I planned to use for it this Custom Field "Dane przycisku rezerwacji". Is this possible?

But actually when I moved this shortcode which you prepared for me in this Pakiet template to single post I can changed this OfferID individually in every of Pakiet. And it is quite good solution for me because I can decide when and in which part of Pakiet content this button should be 🙂

So thanks a lot once again for your support!
Toolset catapulted my sites for next level and I love it! 🙂

#2043475

Hi,

Thanks for writing back and glad that Luo's solution helped.

He is on vacation and will be able to follow up on this ticket when he gets back tomorrow.

Thank you for your patience.

regards,
Waqar

#2045455

Hello,

For the question:

And I planned to use for it this Custom Field "Dane przycisku rezerwacji". Is this possible?

Yes, it is possible, you can use [wpv-post-field] for it, for example, I have changed the shortcode block codes to:

<button class="vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-square vc_btn3-style-3d vc_btn3-block vc_btn3-icon-left vc_btn3-color-danger" onclick="Booking.Open({OfferID:[wpv-post-field name='wpcf-dane-przycisku-rezerwacji']}); return false;"><i class="vc_btn3-icon vc_li vc_li-pen"></i> REZERWUJ ONLINE</button>

It works fine for custom field "Dane przycisku rezerwacji" in front-end:
hidden link

#2045487

My issue is resolved now. Thank you vary much Luo!