AnsweredAssumed Answered

Check hidden field value before assigning a value.

Question asked by c083dbf7a77dba263753b3aefe52d8bfdc21f082 on Nov 11, 2015
Latest reply on Nov 12, 2015 by c083dbf7a77dba263753b3aefe52d8bfdc21f082

We want to use a master form for landing pages hosted on our own site.  We're able to do this and assign campaign ID, assets and the redirect url as needed with the following code:


<script src="//"></script>

<form id="mktoForm_ourFormID"></form>


  MktoForms2.loadForm("//", "ourID", ourFormID, function(form) {

  // Set values in hidden fields to determine campaign and asset to serve





  // Override master redirect URL set in Marketo

  form.onSuccess(function(values, followUpUrl) {

  location.href = "newRedirectURL";

  // Return false to prevent the submission handler continuing with its own processing

  return false;





The next step is to assign the campaign iD only if it's not already included in the referring url.  So I need some sort of if/then statement that looks at the hidden campaign ID to see if there's a value - and assign a value only if there is not.  I'm not a javascript master by any stretch, and I'm not sure what is the best method for the Marketo API.  Can someone help me with this last bit of if/else?