I have some JS variables set in the head due to them outputting ACF values from WordPress posts (in this case URLs).
<head>
<script>
pdf1 = 'https://url.com/file1.pdf';
pdf2 = 'https://url.com/file2.pdf';
...
</script>
</head>
I need to output these values on the submission of a single form, and redirect to the URLs in the vars above. The values should increment based on the number in the vars. I also need to increment the cookie ID too.
Where X exists, I need something to increment the values.
$('#form_id1').submit(function(i, varX) {
$(this).each(function() {
// some code to close a modal I already have.
setTimeout(function() {
jQuery.cookie('cookie-' + i);
// redirect to the selected URL
jQuery(location).attr('href', pdfX);
}, 1000);
})
});
I've done some research and I've tried using pdf++.
I've tried something like:
jQuery(location).attr('href', pdf + 1);
Below is the closest I got.
id = 1;
$('#form_id1').submit(function(i, pdfX) {
$(this).each(function() {
id = id + 1;
// some code to close a modal I already have.
setTimeout(function() {
jQuery.cookie('cookie-' + id);
// redirect to the selected URL
jQuery(location).attr('href', pdfX);
}, 1000);
})
});