Jump to content

OnClick function for Button

Recommended Posts

I'm having the same problem with the onclick function. The site I'm working on has multiple forms for each location. I'm wanting a form to display based on the button of the location clicked. I'm tried the following code to simply test if it works but it doesn't seem to. 

<div class="sqs-block button-block sqs-block-button">
  <div align="center">
  <a onclick="myFunction()" 
     class="sqs-block-button-element--large sqs-block-button-element" target="_blank">Test Form</a>
  </div>
</div>

<script>
function myFunction () {

<a href="javascript:;" onclick="testform('show')">
}
</script>

I've tried with adding this all under the Code block as well as splitting the HTML into a Code Block and the Script into a Code Injection in the Header but neither one works.

The site is this: https://duck-octagon-2m8x.squarespace.com/home - the button I'm testing is in the last section before the footer.
PW: hQQ&8

Any help is appreciated!!

Link to comment
On 6/22/2023 at 6:01 AM, DaisyJ said:

I'm having the same problem with the onclick function. The site I'm working on has multiple forms for each location. I'm wanting a form to display based on the button of the location clicked. I'm tried the following code to simply test if it works but it doesn't seem to. 

<div class="sqs-block button-block sqs-block-button">
  <div align="center">
  <a onclick="myFunction()" 
     class="sqs-block-button-element--large sqs-block-button-element" target="_blank">Test Form</a>
  </div>
</div>

<script>
function myFunction () {

<a href="javascript:;" onclick="testform('show')">
}
</script>

I've tried with adding this all under the Code block as well as splitting the HTML into a Code Block and the Script into a Code Injection in the Header but neither one works.

The site is this: https://duck-octagon-2m8x.squarespace.com/home - the button I'm testing is in the last section before the footer.
PW: hQQ&8

Any help is appreciated!!

I don't see this button. Can you take a screenshot?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.