SOLVED

save a var into a hidden form field

Go to solution
Anonymous
Not applicable

save a var into a hidden form field

Hello,

I am having trouble with saving the google cliend id (cid) into a hidden field. I am able to get the cid, get it written out in an alert, in a var and as a string, but the last step to save it is taunting me...

Is there someone here who have done this and can tell me where I am messing it up? (I have double checked that the form field name is correctly written)

Please, I already shaves my head but I'm going bold here!!

<script>MktoForms2.loadForm("//app-lon02.marketo.com", "***-***-***", ****, function(form) {

  function getgacid() {

              try {

                var tracker = ga.getAll()[0];

                return tracker.get('clientId');

              } catch (e) {

                return 'n/a';

              }

            }

  var gacid = getgacid();

  var cid = gacid.toString();

  form.vals({"SE_OS_40":"cid", 'SE_OS_50':cid});

    alert("Funkar! cid= " + getgacid() + "& " + gacid + " & cid :" + cid);

        });

      </script>

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: save a var into a hidden form field

form.addHiddenFields(), not form.vals/setValues.

View solution in original post

2 REPLIES 2
Josh_Hill13
Level 10 - Champion Alumni

Re: save a var into a hidden form field

this would be Sanford Whiteman 2 (FigureOne)​ who can help.

SanfordWhiteman
Level 10 - Community Moderator

Re: save a var into a hidden form field

form.addHiddenFields(), not form.vals/setValues.