1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Query in form_X javascript

Discussion in 'Community' started by Mono, Mar 12, 2019.

  1. Mono

    Mono Member

    Level: Community
    Hope someone can put me straight, I'm learning all sorts of new stuff here.

    I understand that I can't query the database in Javascript, but I read that you can with jquery but I must admit it doesn't make sense to me and I can't find an example to learn from.

    What I'm thinking to do is run a switch command based on the number of records in a table with a where clause. This would be the query I would use if I could.

    Code (Text):
    SELECT COUNT(*)
    FROM tbl_faults
    WHERE fk_inspection_id = {tbl_inspections___id} AND im_id = {tbl_inspections___calc_im_id}
    This is why I want to do this:
    I have a pop up form that opens to enter, edit or view records, it has a repeat group and a parent group.

    So when my user clicks 'new' it opens the pop up and puts in some predetermined values into fields and the user completes the 'fault description' and 'fault rectification' for an IM group lets say called 'engine'.

    If my user saves this form and then wants to add another 'new record' to the 'engine group' (im_id), I want to check if there is already any 'fault description' and 'fault rectification' in the engine group and if there is get the rowid that already exists and add to that. Hopefully displaying a blank repeat group at the top of the previously entered records.

    Same for viewing and editing but without the blank repeat group.
     
  2. startpoint

    startpoint Active Member

    Level: Community
    Code (Javascript):
    https://fabrikar.com/forums/index.php?threads/retrieve-values-from-db-using-js.49015/#post-256364
    Whit this sample code you can run query and get get data from db.
    Change it according to your needs.
    Another code examples:
    Code (Javascript):
    https://fabrikar.com/forums/index.php?threads/user-ajax-dropdown.49376/#post-257847
     
  3. Mono

    Mono Member

    Level: Community

    Thank you. I will get reading right away
     
  4. Mono

    Mono Member

    Level: Community
    Thanks startpoint this helped me work it out.
     

Share This Page