save a var into a hidden form field | Community
Skip to main content
August 6, 2016
Solved

save a var into a hidden form field

  • August 6, 2016
  • 2 replies
  • 1871 views

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>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 6, 2016

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

Josh_Hill13
New Participant
August 6, 2016

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