Skip navigation
mdjco
Currently Being Moderated

Add a change event to prompt a function return different result

Jul 17, 2012 7:44 AM

Tags: #adobe #javascript #forms #livecycle

I have a change event in a drop down list, DDL_1, that calls a function from my variables. This DDL_1 returns a value to a text box, Text_1, that I use to calculate time. Inside this change event in DDL_1 I have a conditional statement that is based on user input from a date field, Date_1.

 

My issue is that I need the text box to update/change when I change the value in Date_1 and not just in the DDL_1. I can get the proper value if I change Date_1 and then choose a different value in DDL_1 and select the initial value again, but I'd like the data in Text_1 to automatically change whenever either fields are changed. I suspect there is some capability with the change event of Date_1 but I thought maybe there was a very simple command I could insert and wanted to go to the experts for best practice.

 

The code in the change event of DDL_1 follows this psuedo-code format:

 

if(Date_1 > somedate && Date_1 < someotherdate){

execute function with certain data

}

else{

execute function with different data

}

 
Replies
  • Currently Being Moderated
    Jul 17, 2012 5:08 PM   in reply to mdjco

    Why don't you put that code in the layoutReady event instead of the change event and just add an extra if condition that the dropdown list == whatever.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 12:32 PM   in reply to mdjco

    Hi,

     

    I wouldn't go down the layout:ready event route as overusing this event in a form can lead to performance issues. See here: http://assure.ly/nB0Bvz.

     

    Instead why not have the script in the calculate event of the textfield? This way when ever the date or dropdown are changes the calculate event in the textfield will fire.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 12:34 PM   in reply to mdjco

    I'd put your script in the calculate event of Text_1.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 1:55 PM   in reply to mdjco

    Hi,

     

    It could be from an example, but without seeing the form/script it is difficult to say.

     

    I would still recommend the calculate event of the textfield as the best option.

     

    Where you have script in the change event of the dropdown, you would also need to add script into the exit event of the date field. This would reset the value of the textfield when the user exits. However this will not give as good a user experience, depending on the sequence the user follows when compling the form.

     

    Maybe if you could share your form. If you can upload it to a file sharing site; publish it; and then post the published URL here.

     

    Niall

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points