• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: AutoFill Text Box on date selected

AutoFill Text Box on date selected 1 year 1 month ago #42660

Is it possible to Auto Fill the text Boxes with Date + 1, Date + 2, Date + 3 etc.
In the attached I have a Date Dropper and 14 Text fields, is I select example 20 March the field Mon should be auto fill to 20 March, Tue to 21 March, Wed to 22 March and so on till the last Sun that should auto fill to 2 April.

The administrator has disabled public write access.

AutoFill Text Box on date selected 1 year 1 month ago #42673

I managed to get this to work the way I want to but it only works in Mozilla Firefox.
Edge, Chrome and Safari return "NaN-Invalid Date"

I created a Calendar field called "date_select", with Date Format "DD-MM" and then 14 Textboxes
Then added the code below to CSS and Javascript >> Javascript
<script type="text/javascript">
function rsfp_onSelectDate(selectedDate)
{
  // Get the input fields by their IDs - Week 1
  var dateField1 = document.getElementById('week1_mon');
  var dateField2 = document.getElementById('week1_tue');
  var dateField3 = document.getElementById('week1_wed');
  var dateField4 = document.getElementById('week1_thu');
  var dateField5 = document.getElementById('week1_fri');
  var dateField6 = document.getElementById('week1_sat');
  var dateField7 = document.getElementById('week1_sun');
  // Get the input fields by their IDs - Week 2
  var dateField8 = document.getElementById('week2_mon');
  var dateField9 = document.getElementById('week2_tue');
  var dateField10 = document.getElementById('week2_wed');
  var dateField11 = document.getElementById('week2_thu');
  var dateField12 = document.getElementById('week2_fri');
  var dateField13 = document.getElementById('week2_sat');
  var dateField14 = document.getElementById('week2_sun');
 
  // Convert the selected date to a JavaScript Date object
  var date = new Date(selectedDate);
 
  // Set the values of the input fields - Week 1
  dateField1.value = formatDate(date);
  date.setDate(date.getDate() + 1); // Increment date by 1 day
  dateField2.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField3.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField4.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField5.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField6.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField7.value = formatDate(date);
    // Set the values of the input fields - Week 2
  date.setDate(date.getDate() + 1); // Increment date by 1 day
  dateField8.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField9.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField10.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField11.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField12.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField13.value = formatDate(date);
  date.setDate(date.getDate() + 1);
  dateField14.value = formatDate(date);
  return true;
}
 
// Helper function to format the date as DD-MM-YYYY
function formatDate(date) {
  var day = date.getDate().toString();
  var month = date.toLocaleString('default', { month: 'short' });
  return day + '-' + month;
}
</script>
FireFox:


Edge, Chrome and Safari:


Can Anyone please assist me in why it is not working in Edge, Chrome and Safari?
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!