• 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: New variable in PDF document

New variable in PDF document 1 year 3 months ago #42496

  • info9642
  • info9642's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hello,

can someone please help me with a small problem?

I made a code to show a specific month in my PDF form when a specific value is selected in the "Dropdown" field.

I pasted the code at: Manage Forms > your form > Properties > CSS and JavaScript > JavaScript.
 
let currentMonth = new Date().getMonth();
let nextMonth = (currentMonth == 11) ? 0 : currentMonth + 1;
let monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December "];
let nextMonthName = monthNames[nextMonth];
 
console.log(nextMonthName); "


But how can I use the variable "nextMonthName" on the PDF? so {nextMonthName} so neither {nextMonthName:value}

Best regards
The administrator has disabled public write access.

New variable in PDF document 1 year 3 months ago #42503

  • iceferret
  • iceferret's Avatar
  • NOW ONLINE
  • Gold Boarder
  • Posts: 213
  • Thank you received: 57
Amended your code slightly but this should work. It assigns the value of nextMonthName to a hidden field in your form called 'month' - call the function by adding onclick="date();" to the additional attributes of the submit button then you can add {month:value} to your PDF. B)
function date() { 
 
let currentMonth = new Date().getMonth();
let nextMonth = (currentMonth == 11) ? 0 : currentMonth + 1;
let monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December "];
let nextMonthName = monthNames[nextMonth];
 
document.getElementById("month").value = nextMonthName;
}
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
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!