How can I create/add custom javascript to a form to calculate fields?

  • Profile Image
    ericbojo
    Asked on April 22, 2013 at 06:18 PM

    I want to have a form Calculate a value based on 2 fields.   For this i need to add custom javascript to the form to  multiply and divide 2 field values and then insert that value into a new field.  How can I add my custom javascript to  the form?

  • Profile Image
    falkirks
    Answered on April 22, 2013 at 06:55 PM
    You can download the complete source code of the form using the embed tab.
    Then make the customizations required.
  • Profile Image
    abajan
    Answered on April 22, 2013 at 07:39 PM

    @ericbojo

    Do you already have a script, or would you like assistance with that?

  • Profile Image
    ericbojo
    Answered on April 22, 2013 at 07:56 PM

    Oh, I already have the basic script written. Its good I can download it and use it on my site since i prefer using jQuery when possible

  • Profile Image
    jonathan
    Answered on April 22, 2013 at 11:25 PM

    @ericbojo

    Hi,

    Try this steps.

    1. Download your form's source code.

    2. Embed/Add the form using source code to your website page.

    3. Add your script to that same page where the form was embedded.

    Example page (this is from Abajan's old sample page)

    Put numbers on "Chicken" or "Mutton Briyani" field and you will see the "total" field calculates

    ---

    You can view the source of this page and you will see the javascript code part at the bottom.

     

    Hope this help. Inform us if you need further assistance.

    Thanks.

  • Profile Image
    designer47
    Answered on September 21, 2016 at 09:24 AM

    how to disable a button in my form ?

  • Profile Image
    Jan
    Answered on September 21, 2016 at 10:52 AM

    @designer47

    This is a duplicate post. I can see that you already opened your own thread. Please refer to that thread, here's the link: https://www.jotform.com/answers/937951.

    Thank you.