How do I setup a button to run a script

Hi All,

I’m used to setting up very basic buttons using the excellent ButtonPlus2, but normally I am just adding a link.

I need to add a button that when pressed triggers something like this:

<a href="#" id="go" onclick="mychatbot.start()">Start</a>
    <script type="text/javascript" 
    src="https://mychatbot.com/qb/widget/mctests3/3MY12wr84drd8ARO">
    </script>

Most of my buttons use ButtonPlus2, but I’m happy to use whatever button/stack is necessary.

Sorry for being so thick and thank you in advance for any help.

We can’t see what you’re trying to start.

When you place code in this Forum you need to highlight it and mark it as code </> right above the typing area.

1 Like

Thanks @Teefers

I’ve edited it above so it is now showing the code.

1 Like

You should be able to split the javascript out and either place the script (with script tags) in an HTML stack.

 <script type="text/javascript" 
    src="https://mychatbot.com/qb/widget/mctests3/3MY12wr84drd8ARO">
    </script>

Or remove the script tag and place in the code(JavaScript) section of the page.

src="https://mychatbot.com/qb/widget/mctests3/3MY12wr84drd8ARO">

Then when you set up the button:

  1. URL to #
  2. custom attributes add the following
    • id go
    • onclick. mychatbot.start()

2019-01-09_04-42-31

5 Likes

@Teefers Thanks for that great explanation. I will give that a go this evening. Much appreciated