More options to auto-populate a hidden field value on a form

More options to auto-populate a hidden field value on a form

It would be great if the form editor provided the ability to automatically populate a hidden field with a unique value that would be dependent on whatever value was entered in another field on the same form. Currently the only options we have to set the hidden field value is via a default value, URL parameter, cookie value, or referrer parameter. It would be be helpful if we had the ability to add dynamic rules/conditions based on the other field value. For example, if the value for the field: Areas of Interest is "A" then always populate hidden field: Areas of Interest link with "www.A.com"  This would come in handy when it comes to creating confirmation/thank-you emails leveraging tokens. 
2 Comments
Marketo Employee
Hi Peter,

It may not be precisely what you're looking form, but this functionality is available to some extent via the Forms 2.0 Javascript API.  Typically checking like this is done during onValidate or onSubmit like so:

<script>
MktoForms2.onValidate(function(form){
var myValue = "something goes here" //set a value you want to check
if( form.getVals().myField == myValue){ //see if your value matches
form.addHiddenFields({ "newField":"newValue"}; //add the hidden field and value
} //iterate with else if here if necessary
});
</script>
Community Manager
Status changed to: Open Ideas