Brett McCumber
April 24, 2015 at 10:06 am
Hi there,
I’m trying to have a pre-checked checkbox in the checkout page. I know using jquery I can use the following:
$(document).ready(function(){
$('.checkbox').prop('checked', true);
});
But I’m just not sure in what file and where to put it in. Please advise. Thank you.
Brett McCumber
April 24, 2015 at 10:06 am
Add New Note to this Reply
Hi there,
I’m trying to have a pre-checked checkbox in the checkout page. I know using jquery I can use the following:
$(document).ready(function(){
$('#Yes-358_1').prop('checked', true);
});
But I’m just not sure in what file and where to put it in. Please advise. Thank you.
Dean
April 27, 2015 at 1:26 am
Add New Note to this Reply
Hi,
Personally I would add it to a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/ ), something like:
add_action('wp_footer', 'checkthis');
function checkthis() {
if( is_page(4) ) {
?>
<script>
jQuery(document).ready(function(){
jQuery('#ee_reg_qstn-30-12-one').prop('checked', true);
});
</script>
<?php
}
}
Which will add the script to the footer area.
Brett McCumber
April 27, 2015 at 10:13 am
Add New Note to this Reply
Thank you.
Brett McCumber
May 8, 2015 at 9:57 am
Add New Note to this Reply
It works when using Cart or Registering only one Attendee. When I use “Add more attendees” option the checkbox stays unchecked.
Code used:
add_action('wp_footer', 'checkthis');
function checkthis() {
?>
<script>
jQuery(document).ready(function(){
jQuery('.MULTIPLE_13').prop('checked', true);
});
</script>
<?php
}
Lorenzo Orlando Caum
May 8, 2015 at 10:55 am
Add New Note to this Reply
Hi, this doesn’t work as expected because those additional fields are activated as you add additional attendees by clicking on the button.
The jQuery runs on the initial page load so it won’t be able to pick those up afterwards.
—
Lorenzo
Brett McCumber
May 8, 2015 at 11:13 am
Add New Note to this Reply
Would I be able to run the script every time the button clicked? What file can I fin that in?
Thank you Lorenzo. You are and have been a huge help!
Lorenzo Orlando Caum
May 11, 2015 at 7:39 am
Add New Note to this Reply
Hi, that would not work as expected since the sample jQuery that was shared is set to run on the initial page load.
—
Lorenzo