Jump to content

Two conflicting Scripts on Webpage. Need Help

Recommended Posts

Site URL: https://www.athlytic.io

I'm having an issue with a client site where I am attempting to change the placeholder text on a newsletter block.  I have added the following script to my code injection footer, however, it is not changing:

<script>
  if (document.querySelector("#block-yui_3_17_2_1_1616980347389_14059")) {
    document.querySelector('.newsletter-form-field-element[name="fname"]').placeholder = 'Name';
    document.querySelector('.newsletter-form-field-element[name="lname"]').placeholder = 'Phone Number';
    document.querySelector('.newsletter-form-field-element[name="email"]').placeholder='Email Address';    
  }
</script>

I'm assuming, it's because there is an embedded script within a section on the homepage that is being ran, which hides a portion of content within that section until a button is clicked.  The following code has been applied to the code injection for the home page specifically to get the button to toggle the content on and off

<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>

<style>
.button-section{text-align:center;border-radius:6px;width:350px;display:flex;flex-flow:row wrap;align-items:center;margin:auto;box-sizing:border-box;padding-bottom:35px}

.button-single{text-transform:uppercase;font-size:.7em;text-align:center;letter-spacing:.2em;vertical-align:middle;box-sizing:border-box;width:50%}

.button-left{border-top-left-radius:10px 10px;border-bottom-left-radius:10px 10px}

.button-right{border-top-right-radius:10px 10px;border-bottom-right-radius:10px 10px}
</style>

I need both scripts to work but my knowledge of Javascript is extremely limited and I am struggling getting the newsletter block to display the correct placeholder text for the client.  

Any and all help is extremely appreciated.

Link to comment
26 minutes ago, adc said:

Site URL: https://www.athlytic.io

I'm having an issue with a client site where I am attempting to change the placeholder text on a newsletter block.  I have added the following script to my code injection footer, however, it is not changing:

<script>
  if (document.querySelector("#block-yui_3_17_2_1_1616980347389_14059")) {
    document.querySelector('.newsletter-form-field-element[name="fname"]').placeholder = 'Name';
    document.querySelector('.newsletter-form-field-element[name="lname"]').placeholder = 'Phone Number';
    document.querySelector('.newsletter-form-field-element[name="email"]').placeholder='Email Address';    
  }
</script>

I'm assuming, it's because there is an embedded script within a section on the homepage that is being ran, which hides a portion of content within that section until a button is clicked.  The following code has been applied to the code injection for the home page specifically to get the button to toggle the content on and off


<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>

<style>
.button-section{text-align:center;border-radius:6px;width:350px;display:flex;flex-flow:row wrap;align-items:center;margin:auto;box-sizing:border-box;padding-bottom:35px}

.button-single{text-transform:uppercase;font-size:.7em;text-align:center;letter-spacing:.2em;vertical-align:middle;box-sizing:border-box;width:50%}

.button-left{border-top-left-radius:10px 10px;border-bottom-left-radius:10px 10px}

.button-right{border-top-right-radius:10px 10px;border-bottom-right-radius:10px 10px}
</style>

I need both scripts to work but my knowledge of Javascript is extremely limited and I am struggling getting the newsletter block to display the correct placeholder text for the client.  

Any and all help is extremely appreciated.

I saw you made it changed, what's wrong

image.thumb.png.a2b6af1b0e38f9be736d414ef8ccc80d.png

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

When you click 'Brands' a Newsletter Block appears but it doesn't say:

Name

Phone Number

Email Address

it instead has the default placeholder text for a newsletter block:

First Name

Last Name

Email Address

The code is suppose to change the placeholder text but it doesn't appear that way once the hidden content is revealed upon the button click of the 'Brands' tab.

Link to comment
On 4/1/2021 at 10:47 AM, adc said:

When you click 'Brands' a Newsletter Block appears but it doesn't say:

Name

Phone Number

Email Address

it instead has the default placeholder text for a newsletter block:

First Name

Last Name

Email Address

The code is suppose to change the placeholder text but it doesn't appear that way once the hidden content is revealed upon the button click of the 'Brands' tab.

It looks like you solved this? 

On tablet, looks huge spacing. Do you want to adjust it?

image.thumb.png.c124e8c314c1d3d6c979f268d409dd79.png

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

This issue has not been solved.  Please see attached images to better understand what I'm referring to.

If you would like to provide the code to adjust the spacing for tablet you can just for my better understanding, but the client has not requested that be changed.

Thanks.

Screen Shot 2021-04-05 at 9.24.54 AM.png

Screen Shot 2021-04-05 at 9.24.59 AM.jpg

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.