Skip to main content
juliusc67934969
Participating Frequently
November 10, 2020
Answered

populating textfield based on the drop list selection.

  • November 10, 2020
  • 3 replies
  • 2523 views

Hello my Friends,

 

I need your help for this problem and I need the code for this issue.

 

Here the details for this form.

 

In the the Status Dropbox there 3 categories ( Pending, Invoice and Release)

 

When I select the “Pending  Status in  dropbox, then select the Reservation date and select the Deposit Dropbox (yes or No) then result in Over due text box

if “yes” selection from deposit dropbox  = display in overdue textbox is “14 days"

If  no” selection from deposit dropbox = display in overdue textbox is “ 3 days”  

If the status select, invoice and release not showing the overdue. Mean blank only. Only the Pending showing the output in over due textbox.

 

Please refer the sample in excel in attached. So that you have idea what I mean.   The main point there is if you change the date automatic the over due is change the no. of days.

 

Also, the pdf file sample but without code in over due because I don’t know how to do it.

 

Thanks you advance for you help.

This topic has been closed for replies.
Correct answer Nesa Nurani

also, if  I want to change the date example below.

 

10/10/2020  - the result in over due is  -8 days

12/20/2020 - the result in over due is 53 days.

 

you can see there the sample in excel.

 


See if this works for you example 

This is code I put in "OD1" field as custom calculation script:

var today = util.printd("mmmm/d/yyyy", new Date());
var overdue = this.getField("Date1A_af_date").value;
if (today.length && overdue.length) {
var datetoday = util.scand("mmmm d, yyyy", today);
var dateoverdue = util.scand("mmmm d, yyyy", overdue);
var diff = (dateoverdue.valueOf() - datetoday.valueOf())/1000;
var days = (((diff / 60) / 60) / 24);
var res = days+14;
var res2 = days+3;}
if(this.getField("Status1").valueAsString == "Pending" && this.getField("Dep1").valueAsString == "Yes"){
event.value = res.toFixed();}
else if(this.getField("Status1").valueAsString == "Pending" && this.getField("Dep1").valueAsString == "No"){
event.value = res2.toFixed();}
else event.value = "";

 

3 replies

Nesa Nurani
Community Expert
Community Expert
November 11, 2020

Put the code in "OD1" field as "Custom Calculation Script"

if(this.getField("Status1").valueAsString == "Pending" && this.getField("Dep1").valueAsString == "Yes"){
event.value = "14 Days";}
else if(this.getField("Status1").valueAsString == "Pending" && this.getField("Dep1").valueAsString == "No"){
event.value = "3 Days";}
else event.value = "";

juliusc67934969
Participating Frequently
November 11, 2020

finally. thanks you Nesa. 🙂 

Inspiring
November 10, 2020

How exactly do you want second part of your question if date is changed to work?

If it's todays date it shows "14 days" and lets say its November 14 2020 what does it need to show then?

juliusc67934969
Participating Frequently
November 11, 2020

Hi Asim,

 

Anyway forget the second question.  Sorry for that.

 

I need only the code for that 1st part. Please can you help me this.

Bernd Alheit
Community Expert
Community Expert
November 10, 2020

You can find scripts for this in the forum.

juliusc67934969
Participating Frequently
November 10, 2020

Hi Bernd, please can you find me. because i try to find this same question but unfortunely I did see the script what I'm looking for. 

 

 

Bernd Alheit
Community Expert
Community Expert
November 10, 2020

Look also at "Related conversations".