Announcement

Collapse
No announcement yet.

onChange Event Order

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • onChange Event Order

    Just wondering if someone could verify the onchange processing order within Scriptcase and provide a possible solution.

    I have a select listbox which is dependent on 2 other select listboxes. I'll try to describe this the best I can.

    Select ListboxA
    OnChange event to look up a value
    Store the value in a global variableA
    Select ListboxB
    OnChange event to look up a value
    Store the value in a global variableB

    For each of the data types above, I also have the Ajax Processing EVENTS onChange configuration set to refresh a select listboxC. The lookup query for listboxC uses the global variables above as predicates in the query.

    What I'm noticing is the Ajax Processing EVENTS onChange for listboxA or listboxB fires before the onChange events for ListboxA or ListboxB. So the global variables are not set until after the listboxC lookup query executes. So the new global variable values are not used in the query. Is there a way to force the Ajax Processing EVENTS onChange event from the onChange event for listboxA or listboxB?
    Last edited by pkrawetzky; 04-25-2014, 11:21 AM.

  • #2
    Originally posted by pkrawetzky View Post
    Just wondering if someone could verify the onchange processing order within Scriptcase and provide a possible solution.

    I have a select listbox which is dependent on 2 other select listboxes. I'll try to describe this the best I can.

    Select ListboxA
    OnChange event to look up a value
    Store the value in a global variableA
    Select ListboxB
    OnChange event to look up a value
    Store the value in a global variableB

    For each of the data types above, I also have the Ajax Processing EVENTS onChange configuration set to refresh a select listboxC. The lookup query for listboxC uses the global variables above as predicates in the query.

    What I'm noticing is the Ajax Processing EVENTS onChange for listboxA or listboxB fires before the onChange events for ListboxA or ListboxB. So the global variables are not set until after the listboxC lookup query executes. So the new global variable values are not used in the query. Is there a way to force the Ajax Processing EVENTS onChange event from the onChange event for listboxA or listboxB?

    Yes. Go to the field listboxA and scroll down to the ajax event on the right side of your screen and check the checkbox. There you can select Listboxb to be refreshed when Listbox a is changed. That should do it.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Unfortunately that won't work because I'm trying to refresh listboxC when either A or B is changed (listboxA and listboxB are independent of each other - listboxC is dependent on the values form listboxA and listboxB). Because ListboxC has a lookup that uses the global variables set onchange of listboxA or listboxB, the firing order of the onchange events does not update the global variables first.

      When I repeat the process by updating listboxA or listboxB, listboxC is finally updated with the old values in the global variable from the first set of changes.

      Comment


      • #4
        Let try with an example:

        On form load:
        listboxA = 1
        globalvariableA = 1
        listboxB = 2
        globalvariableB = 2
        listboxC = 77 (it has a lookup query where column1 = globalvaraibleA and column2 = globalvariableB)

        Select a new value in listboxA
        listboxA = 2 (the onchange event does not fire to update globalvariableA with the new value)
        listboxA has Ajax Processing EVENTS onChange configuration set to refresh a select listboxC
        listboxC is refreshed using globalvariableA (value 1) and globalvariableB (value 2)
        listboxA onChange event (listboxA_onchange) fires and sets globalvariableA = 2
        since listboxC has already been refreshed with the old values, listboxC is not updated using the new globalvariableA's value

        Select a new value in listboxA
        listboxA = 3 (the onchange event does not fire to update globalvariableA with the new value)
        listboxA has Ajax Processing EVENTS onChange configuration set to refresh a select listboxC
        listboxC is refreshed using globalvariableA (value 2) and globalvariableB (value 2)
        listboxA onChange event (listboxA_onchange) fires and sets globalvariableA = 3
        since listboxC has already been refreshed with the old values, listboxC is not updated using the new globalvariableA's value

        See the pattern? ListboxC refresh is always one value behind.

        What has to happen is the globalvariableA or globalvariableB need to change before the Ajax Processing EVENTS onChange event is triggered. But Scriptcase onchange even triggering does not allow me to change this. Ideally I want to trigger the Ajax Processing EVENTS onChange within my own onchange event.
        Last edited by pkrawetzky; 04-22-2014, 10:26 AM.

        Comment


        • #5
          I decided to change the database table definition so the values used by the query are taken directly from the dependent listboxes.

          Comment

          Working...
          X