Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

javascript not working on pop up

gagan m s February 2, 2018

hello the below code does work on the create issue pop up or when issue type is changed.

it is the code to add business days to due date depending upon the priority value.

any help is appreciated.

<script>
function validate()
{
var now = new Date();
if(document.getElementById("customfield_18094").value == 28180 )
{
    days = 5;
}
else
    if(document.getElementById("customfield_18094").value == 28181 )
    days = 1;
else
    
    days = 3;


  var dayOfTheWeek = now.getDay();
  var calendarDays = days;
  var deliveryDay = dayOfTheWeek + days;
  if (deliveryDay >= 6) {
    days -= 6 - dayOfTheWeek;
    calendarDays += 2;
    deliveryWeeks = Math.floor(days / 5);
    calendarDays += deliveryWeeks * 2;
  }
  now.setTime(now.getTime() + calendarDays * 24 * 60 * 60 * 1000);
  var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var today = new Date();
today = now;
var numberOfDaysToAdd = 7;
//today.setDate(today.getDate() + numberOfDaysToAdd);
var dd = today.getDate();
var mm = today.getMonth();
var yyyy = today.getFullYear();
today = dd + '/' + monthNames[mm] + '/' + yyyy;
document.getElementById("customfield_18091").value = today;
if(!document.getElementById("customfield_18091").value)
{alert("empty")}
return false;
}
document.getElementById("customfield_18094").addEventListener("change", validate);
</script>

1 answer

0 votes
Kyle Moseley
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2018

Do you get any error message from the browser console?

Suggest an answer

Log in or Sign up to answer