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

How to find "join id"?

Discussion in 'Community' started by bluetoothbj, Jan 14, 2020.

  1. bluetoothbj

    bluetoothbj Member

    Level: Community
    Dear Sir:
    About "Calculating Cost in a repeat group ", there is a code on end of this page :
    "var i = this.id.match(/_(\d+)$/)[1];
    document.id('join___12___order___total_'+i).value = parseFloat(document.id('join___12___order___qty_'+i).value) * parseFloat(document.id('join___12___order___unit_price_'+i).value);"

    Note "Replace '12' with your join id (execute your form and look at the code to find this ID)"
    How to "execute your form and look at the code to find this ID".
    I don't understand.Could give me a detail instruction to find the join ID?

    Many thanks!
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    Can you post a link to this page? I have the feeling this is outdated.
     
  3. bluetoothbj

    bluetoothbj Member

    Level: Community
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    I have updated the WIKI with what I think is working now.
     
  5. bluetoothbj

    bluetoothbj Member

    Level: Community
    Thanks troester,
    I added JS on both quantiy and price elements ,But the Total element didn't display calculate data,If the Total element need some additional setting?

    cal0.JPG
     
    Last edited: Jan 19, 2020
  6. troester

    troester Well-Known Member Staff Member

    Level: Community
    In your JS there's a _ missing at the end of all your element names.

    Gesendet von meinem SM-G930F mit Tapatalk
     
  7. bluetoothbj

    bluetoothbj Member

    Level: Community
    Thanks troester,
    No I added "_",Still no calculated value:
    cal11.JPG

    cal12.JPG

    Displayed "NaN". What is the reason?
    Thanks?
     
  8. troester

    troester Well-Known Member Staff Member

    Level: Community
    I assume you didn't input numbers.
     
  9. bluetoothbj

    bluetoothbj Member

    Level: Community
    Inputted:


    It display NaN if I set the field as Text;
    But it display nothing if I set the field as number:
     
    Last edited: Jan 19, 2020
  10. troester

    troester Well-Known Member Staff Member

    Level: Community
    ??
    Looks like "Part Cost" and "Part Total" etc. are correct.

    In your screenshot ew_claim-Part_cost_with_tax is obviously no field element but some sort of dropdown.
     
  11. bluetoothbj

    bluetoothbj Member

    Level: Community
    "Part Cost" and "Part Total" is Calc type element. "ew_claim-Part_cost_with_tax" is field type element.
     
  12. troester

    troester Well-Known Member Staff Member

    Level: Community
    upload_2020-1-19_10-46-55.png
    It doesn't look like...

    The code is working on my site. Check with your browser dev tools which JS is running on which elements, if there are JS errors etc.
     
  13. bluetoothbj

    bluetoothbj Member

    Level: Community
    It will display NaN when I set element to TEXT type:
    txt.JPG
     
    Last edited: Jan 20, 2020
  14. troester

    troester Well-Known Member Staff Member

    Level: Community
    The code is for input fields which have a "value", do the calculation with your original fields not with the calc element.
    (This is not Fabrik but just JS).
    Why don't you use also a calc element for cost-with-tax?
     
  15. bluetoothbj

    bluetoothbj Member

    Level: Community
    This is a repeat group.Calc element only could calculate one row.How to calculate total price when there is many rows?Such as there are many products in shopping cart.
     
    Last edited: Jan 19, 2020
  16. troester

    troester Well-Known Member Staff Member

    Level: Community
  17. bluetoothbj

    bluetoothbj Member

    Level: Community
    Many Thanks troester,
    Your Code works.
    "var i = this.getRepeatNum();
    document.id('order___total_'+i).value = parseFloat(document.id('order___qty_'+i).value) * parseFloat(document.id('order___unit_price_'+i).value);"
     

Share This Page