Need help on Javascript code to check all other boxes when you check a specific one

Highlighted
Level 2

Need help on Javascript code to check all other boxes when you check a specific one

Hi All,

I am working on one of the form when we click on one specific checkbox other check boxes should be checked below is the screenshot.

pastedImage_0.png

My requirement is when we click on Receive All communications checkbox other check boxes will be checked except the unsubscribe checkbox that is available in the form in other section.

Below is the java script code i have used but its not working can any one help me on this

<script src="//app-sj11.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_idno"></form>

<script>MktoForms2.loadForm("//app-sj11.marketo.com", "", idno,function(form) {

    $("#recieve all communication id").change(function () {

        $("#subscriptionNewsletter id").prop('checked', $(this).prop("checked"));

    });

}););</script>

Thanks in Advance

3 REPLIES 3
Highlighted

Re: Need help on Javascript code to check all other boxes when you check a specific one

Hi Naveen,

See this JS example: JSFiddle

Let me know if it worked for you.

Highlighted
Level 2

Re: Need help on Javascript code to check all other boxes when you check a specific one

Thanks Yanir. it perfectly works when the input type is checkbox but when i place the form in Landing page and see the view source i see the input type is Text for check boxes that is why the code is not working.

The highlighted ones are check boxes in the form when we click on Receive All Communications checkbox other check boxes like Subscription blog,Subscription news letter,Subscription news room check boxes will check.

Please see below sample code

pastedImage_0.png

Highlighted

Re: Need help on Javascript code to check all other boxes when you check a specific one

Haa strange.

Ok, I updated the script - please try with the new one.

JSFiddle

If it still doesn't work - could you please provide a link to your LP?