Script to updated a Custom field in marketo form
Hi,
I have a Marketo form with a Custom Field and would like to update it with some value.
What should be the script like?
My Form looks like

In the Click me button, I have the script like below, which does not change the value.
My Goal is to update the COB_CustomData to some value.
Help needed for scripting this kind of function?
<button onclick="myFunction()">Click Me</button>
<script>
function myFunction() {
//alert( 'TEST My Function');
form= MktoForms2.getForm(1573);
//alert(form);
var vals = form.getValues();
alert("Submitted values: " + JSON.stringify(vals));
let mktoFieldsObj = {};
mktoFieldsObj['COB_CustomData']="test";
alert(mktoFieldsObj);
form.setValues(mktoFieldsObj);
form.submit();
}
</script>



