selecting date range and setting default date according to on change select element in moodle form

selecting date range and setting default date according to on change select element in moodle form

by Mohammad Hossain -
Number of replies: 0

Hi,

I am new in moodl plugins. I am looking to select date range and setting the default date in moodle form which will depend on selection value of a drop down value. 

it will be really great if anyone can help me

I have tried this code but does not solve the problem

window.onload = init;

function init() {

    $('#id_term').change(function() {

       $('#id_from').load=('dropdownvalpicker.php'); 

    });

}


    dropdownvaluepicker.php  file

  $year=2019; $month=9;$day=1;// then make timestamp of your date

  $defaulttime = make_timestamp($year, $month, $day);

 // echo $mform->addElement('date_selector', 'from', get_string('from'));

  //echo "$mform->setDefault('from',  $defaulttime)"; 

  echo $defaulttime;

     //code in the form.php file 


 $mform->addElement('date_selector', 'from', get_string('from'),$yearrange);

  $mform->setType('from',PARAM_INT);



Average of ratings: -