I’m working on a simple module where you can click a button and it will set the display of a “pop-up form” to block. The form itself works just fine. I got the pop up to work with a load event listener, but now I need it to appear after a button click. This very simple action seems so difficult with hubspot, or maybe I’m just making a dumb mistake. Can you help me out?
here’s the code
<button class=“cryptoChartButton” onclick=“DisplayPopUp()” type=“button”>{% inline_rich_text field=“pop_up_button_text” value=“{{ module.pop_up_button_text }}” %}</button>
{% set href = module.link_cryptochart.url.href %}
{% if module.link_cryptochart.url.type is equalto “EMAIL_ADDRESS” %}
{% set href = “mailto:” + href %}
{% endif %}
<a href=“{{ href }}”
{% if module.link_cryptochart.open_in_new_tab %}target=“_blank”{% endif %}
{% if module.link_cryptochart.rel %}rel=“{{ module.link_cryptochart.rel }}”{% endif %}
>
{% inline_rich_text field=“link_button_text” value=“{{ module.link_button_text }}” %}
</a>
{% set no_title = True %}
{% if module.form_pop_up.form_id %}
{% form
form_key=‘{{ name }}’,
form_to_use=‘{{ module.form_pop_up.form_id }}’,
no_title=‘{{ no_title }}’,
%}
{% endif %}
<script>
function DisplayPopUp(){
document.getElementsByTagName(“form”).style.display = “block”;
}
</script>
<style media=“screen”>
*,
*:before,
*:after{
padding: 0;
margin: 0;
box-sizing: border-box;
}
form{
opacity: 1;
animation-name: fadeInOpacity;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 1.5s;
background-color: rgba(220, 220, 220, 0.9);
display: none !important;
position: fixed;
z-index: 10000000000;
position: fixed;
width: auto;
max-height: 700px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
@keyframes fadeInOpacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
</style>
