-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_for_ajax_dropdown.php
60 lines (58 loc) · 1.47 KB
/
script_for_ajax_dropdown.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<style type="text/css">
.lesson_form_select {
width: 50% !important;
}
</style>
<script style="text/javascript">
jQuery(document).ready(function (){
prod_course_lessons();
jQuery("#_course_id").on('change' ,function() {
prod_course_lessons();
});
jQuery("#_lesson_id").on('change' ,function() {
//jQuery('#_lesson_id option').prop('selected', true);
if (jQuery("#_all_lessons").prop('checked') == true)
{
var s = 0;
jQuery("#_lesson_id option").each(function() {
if(s > 0){
jQuery(this).attr('selected', 'selected');
}
s++;
});
alert('<?php _e("You cannot Unselect Lesson when All lesson is selected", "learndash_pfl"); ?>');
}
});
});
function prod_course_lessons() {
var courses = jQuery('#_course_id').val();
jQuery.ajax({
type: "POST",
url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
//dataType:"json",
data: {
action: 'get_course_lessons',
courses: courses,
productID: '<?php echo $_GET['post']; ?>'
},
cache: false,
success: function(data)
{
jQuery('#_lesson_id').html(data);
if (jQuery("#_all_lessons").prop('checked') == true)
{
setTimeout(function(){
var s = 0;
jQuery("#_lesson_id option").each(function() {
if(s > 0){
jQuery(this).attr('selected', 'selected');
}
s++;
});
//jQuery('#_lesson_id option').prop('selected', true);
}, 2000);
}
}
});
}
</script>