Regarding the code below - is there a way to make this work only for a specific form ID?
I tried using if (formId == xxxx) in there but couldn't get it working.
Any help would be appreciated.
MktoForms2.whenReady(function(form) {
var formEl = form.getFormElem()[0],
thankYouWindow;
form.onSubmit(function(form) {
thankYouWindow = window.open('');
});
form.onSuccess(function(vals, thankYouURL) {
thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf';
formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.';
return false;
});
});
Solved! Go to Solution.
MktoForms2.whenReady(function(form) {
const formEl = form.getFormElem()[0],
formId = form.getId();
const newTabFormIds = [1234,5678];
if( newTabFormIds.includes(formId) ) {
let thankYouWindow;
form.onSubmit(function(form) {
thankYouWindow = window.open('');
});
form.onSuccess(function(vals, thankYouURL) {
thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf';
formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.';
return false;
});
}
});
MktoForms2.whenReady(function(form) {
const formEl = form.getFormElem()[0],
formId = form.getId();
const newTabFormIds = [1234,5678];
if( newTabFormIds.includes(formId) ) {
let thankYouWindow;
form.onSubmit(function(form) {
thankYouWindow = window.open('');
});
form.onSuccess(function(vals, thankYouURL) {
thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf';
formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.';
return false;
});
}
});
Thank you, Sandford!
Much appreciated.