Ms-data to 3rd party form

Does anyone know how I could use or pass ms-data to info to a 3rd party embedded form I have built on paperform.co? I have the form embedded on my site in my user only section.

Hi @ONEHUB! Can you send me your current code?

I can help with this.

1 Like

That would be great @belltyler thank you.

1 Like

1 Like

Sweet! Would you mind sending the text version? I bet that will save Tyler some time :smiley:

Of course :slight_smile: I included it but it didn’t show up. Im a rookie lol

1 Like

div data-paperform-id=“onehub”>(function() {var script = document.createElement(‘script’); script.src = “https://paperform.co/__embed”; document.body.appendChild(script); })()</script

1 Like

A bit of custom code can do this. Take a look at the input IDs generated by paperform. Assuming they are static (i.e. they are always the same for every user), then you have at least a couple options: (1) use the setAttribute() method to add the correct MemberStack ms-data attribute to the paperform input, or (2) populate the paperform input using JavaScript like this:

MemberStack.onReady.then(function(member) {
   document.getElementById("paperformIDforlastname").value = member["lastname"];
})

If paperform uses names or classes instead of IDs, this is still doable.

2 Likes

Here is example code that pre-fills the name and email. It uses @Scott’s idea of setAttribute which should work great for this.

<div data-paperform-id="onehub"></div>
<script>
    MemberStack.onReady.then(function(member) {
        
        var name = member["name"]
        var email = member["email"]
        
        var pf = document.querySelector("[data-paperform-id='onehub']")
        
        var prefill = "name=" + name + "&email=" + email
        pf.setAttribute("data-prefill",prefill)
        
        var script = document.createElement('script'); 
        script.src = "https://paperform.co/__embed"; 
        document.body.appendChild(script);
        
    })
</script>
1 Like

Fantastic! Thank you so much.

2 Likes