Jump to content

Order Form Custom Code Injection

Recommended Posts

Hey everybody,

Trying to figure out a way to avoid a 3rd party form to include file upload. I injected HTML into the form, and it looks great. However, after submission, the data isn't included in the form storage locations (email and google drive). I assume the reason that doesn't work is because the form is given a unique id upon creation and that id is what is used to transmit data, making the JS injected AFTER the creation of the form invisible in the data transfer. Any ideas on how to get around this?

Here's the code I've injected into the footer:

<script>
    // If on order-form-page, inject file upload element
    if (document.URL.includes('/order-form-test')) {
        document.querySelector('#textarea-yui_3_17_2_1_1572443434525_3770').insertAdjacentHTML('afterend', '<h3>Please Upload Artwork Here</h3><input type="file" id="myFile"><br><br>');

        document.querySelector("#myFile").setAttribute("accept", ".doc,.jpg,.png,.jpeg,.docx,.pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document");
    };
</script>

 

Link to comment
  • Replies 1
  • Views 726
  • Created
  • Last Reply

Please provide the site url that you have activated the code

Thanks dhayes22

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.