Expand my Community achievements bar.

Adobe Journey Optimizer Community Lens 6th edition is out.
SOLVED

Pre-checked checkbox landing page

Avatar

Level 2

Hi

 

I'm creating a landing page for unsubscribe and what it shou;d do:

When opening the landing page, the checkbox for the option 'unsubscribe' should be automatically checked so that the user does not have to do this anymore. I'm trying to get this result with a script, but it's not working.

 

Script:

<script>

window.addEventListener('lpRuntimeReady',function(e){
init(e.detail)
}

function init(lpRuntime){
window.getElementByTagName('acr-form-checkbox-4').checked = true;
})

</script>

 

I'm adding this at the top of my landing page with an html content. Can someone help me and let me know what I'm doing wrong?

 

Thank you!

Kr

Lara

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2

In the mean time my colleague found the solution.

New code:

<script>
window.addEventListener('lpRuntimeReady',function(e) {
init(e.detail)
});

function init(lpRuntime) {
console.log('check unsubscribe checkbox');
document.getElementsByName('acr-form-checkbox-4')[0].checked = true;
}

</script>

View solution in original post

2 Replies

Avatar

Community Advisor

@siljkla  try this code

<script>

// Get the checkbox element

var checkbox = document.getElementsByName("acr-form-checkbox-4");

// Check the checkbox

checkbox.checked = true;

</script>

 

Avatar

Correct answer by
Level 2

In the mean time my colleague found the solution.

New code:

<script>
window.addEventListener('lpRuntimeReady',function(e) {
init(e.detail)
});

function init(lpRuntime) {
console.log('check unsubscribe checkbox');
document.getElementsByName('acr-form-checkbox-4')[0].checked = true;
}

</script>