Announcement

Collapse
No announcement yet.

reload value of the second field when selecting a value in the first field (automatic

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

  • reload value of the second field when selecting a value in the first field (automatic

    Hi there,

    I was wondering why my application isn't working properly:

    I have a table called 'artikelen', as shown below:

    ARTIKELEN
    ---------------------------
    ArtikelID | Artikelnaam (TEXT) | Artikelverkoopprijs (CURRENCY)
    1 product1 €10
    2 product2 €25
    3 product3 €100


    In the database the field 'artikelnaam' is of the type 'varchar(255)' and the field 'artikelverkoopprijs' is of the type 'INT(255)'.
    I've created a form_editable_grid where the fields 'artikelnaam' (label: orderdetailsartikelnaam) and 'artikelverkoopprijs' (label: orderdetailsprijs) are shown. Both fields are of the type 'select'. The SQL of the field 'artikelnaam' is:

    SELECT artikelID, artikelnaam
    FROM artikelen
    ORDER BY artikelnaam


    I also checked the box 'Use AJAX to reload other fields of type Select, Double select, Radio and Checkbox' in the block 'AJAX Events' and turned the asterisk on for the value 'orderdetailprijs' wich is the title (not the field-name) of the second field.

    In the second field (orderdetailprijs) I put the following SQL:

    SELECT artikelID, artikelverkoopprijs
    FROM artikelen WHERE artikelID = '{artikelnaam}'
    ORDER BY artikelverkoopprijs


    When running the form, the values in the first field (artikelnaam) are correctly showed, but when I select an product, the value in the second field (artikelverkoopprijs) should change automatically to the value belonging to the product (artikelnaam). But the second select-box is empty. No values are shown. Please also check the attachments (screenshots).

    What did I do wrong and how can i make this work?

    Thanks in advance!

    Last edited by sfm.broos@live.nl; 01-01-2013, 12:25 PM. Reason: added the two screenshots

  • #2
    Hello,

    From what I could understand, you are passing a Text (the product name) to compare with an ID.

    In the second field (orderdetailprijs) I put the following SQL:

    SELECT artikelID, artikelverkoopprijs
    FROM artikelen WHERE artikelID = '{artikelnaam}'
    ORDER BY artikelverkoopprijs


    Please activate debug mode on the application, and make sure that the SQL parsed is correct.

    regards,
    Bernhard Bernsmann

    Comment

    Working...
    X