Announcement

Collapse
No announcement yet.

Ajax refresh lookup with 2 differents field

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

  • Ajax refresh lookup with 2 differents field

    Hello, i need your help.

    Have you already succeed in using an auto lookup refresh (A list box refresh a second listbox) with ajax with two differents source field from the form
    The lookup works very well :

    SELECT idchantier, libellechantier
    FROM chantier
    WHERE idclient='{idclient}'
    AND actif='1'


    This one, also very well :

    SELECT idchantier, libellechantier
    FROM chantier
    WHERE idclient='{idclient}'
    AND actif='1'
    AND ((datedebut<=now() AND datefin>=now()) OR permanent='1')

    But this one with 3 differents fields failed :
    SELECT idchantier, libellechantier
    FROM chantier
    WHERE idclient='{idclient}'
    AND actif='1'
    AND ((datedebut<='{startdate}' AND datefin>='{enddate}') OR permanent='1')

    As soon as my lookup contains several diffrents fields, the ajax call doesn't send any request to my mysql database.

    Any idea or advise ?

  • #2
    try doing some things:
    1. if you echo the {startdate} and {enddate} what is the format of the date values?
    2. try replacing the startdate by a value like 2019-10-01 and see what happens

    Comment


    • #3
      i found a way.

      The problem is the format of the datefield. I echoed this value when leaving the field and the result was 01102019 (for Octobre 1st).

      So i
      1. SET the internat format to YYYYMMDD
      2. use the DATE in the mysql code to format date

      HTML Code:
      AND ((datedebut<=DATE('{startdate}') AND datefin>=DATE('{enddate}')) OR permanent='1')
      and it should work

      Comment


      • #4
        ONe more thing, shouldnt your startdatt be >= datedebut?

        Comment


        • #5
          Thank you very much nonkelmike.
          You save my day.
          The problem is about to be solved.
          It seems that your screen copy is quite different from mine. I'm on SC 9.4.005. I don't have the field "Internal Format".
          But your proposal like using Date('{field}') is the goog way cause now SC send to my mysql a query.(take a look at the mysql general log).
          So, right now, i'll test with different date format.

          Than you very much for your time. I really appreciate.

          Comment

          Working...
          X