How to do calculations, additions and multiplications in JotForm

  • Profile Image
    testes1
    Asked on June 18, 2013 at 06:25 AM

    How to do calculations, additions and multiplications in JotForm

    Changes are written in red and / or green

    Form 1 and form2

     

    Form1, created in JotForm:

    http://www.leiloesthankyou.idn.pt/geral-registo-da-encomenda1.htm

    Form Cod1:

    <script src="//cdn.jotfor.ms/static/jotform.js?3.1.797" type="text/javascript"></script>

    <script type="text/javascript">

       JotForm.init(function(){

          JotForm.setCalendar("41");

          JotForm.displayLocalTime("hour_41", "min_41", "ampm_41");

              JotForm.setDateTimeRangeChecker("41","Yes")

    ;                     $('input_34').hint('ex: myname@example.com');

          $('input_57').hint('ex: myname@example.com');

          JotForm.description('input_56', '1 produto   oferece 3 apostas<br />2 produtos oferece 4 apostas<br />3 produtos oferece 5 apostas<br />4 produtos oferece 6 apostas<br />5 produtos oferece 8 apostas');

          JotForm.alterTexts({"alphabetic":"This field can only contain letters","alphanumeric":"This field can only contain letters and numbers.","confirmClearForm":"Você tem certeza que quer limpar este formulário?","confirmEmail":"problema com o endereço de e-mail","email":"Digite um endereço de e-mail válido.","gradingScoreError":"Pontuação total deve ser menor ou igual a ","incompleteFields":"Há campos incompletos ...","inputCarretErrorA":"Input should not be less than the minimum value:","inputCarretErrorB":"Input should not be greater than the maximum value:","lessThan":"Your score should be less than or equal to","maxDigitsError":"The maximum digits allowed is","numeric":"Este campo só pode conter pontos e números","pleaseWait":"Por favor aguarde ...","required":"Este campo é obrigatório","requireEveryRow":"Every row is required.","requireOne":"At least one field required.","submissionLimit":"Sorry! Only one entry is allowed. Multiple submissions are disabled for this form.","uploadExtensions":"You can only upload following files:","uploadFilesize":"O tamanho do arquivo não pode ser maior que:"});

       });

    </script>

    <link target="_blank" href="http://cdn.jotfor.ms/static/formCss.css?3.1.797" rel="nofollow noopener" rel="stylesheet" type="text/css" />

    <link type="text/css" rel="stylesheet" target="_blank" href="http://cdn.jotfor.ms/css/styles/pastel.css?3.1.797" rel="nofollow noopener" />

    <link type="text/css" media="print" rel="stylesheet" target="_blank" href="http://cdn.jotfor.ms/css/printForm.css?3.1.797" rel="nofollow noopener" />

    <style type="text/css">

        .form-label{

            width:127px !important;

        }

        .form-label-left{

            width:127px !important;

        }

        .form-line{

            padding-top:12px;

            padding-bottom:12px;

        }

        .form-label-right{

            width:127px !important;

        }

        .form-all{

            width:900px;

            background:000;

            color:rgb(82, 75, 58) !important;

            font-family:'Tahoma';

            font-size:11px;

        }

        .form-radio-item label, .form-checkbox-item label, .form-grading-label, .form-header{

            color:#555555;

        }

     </style>

    <script>

    function somar(){

    form_31641713065347.input_25.value = eval(document.form_31641713065347.input_58.value) * eval(document.form_31641713065347.input_19.value)

    form_31641713065347.input_26.value = eval(document.form_31641713065347.input_59.value) * eval(document.form_31641713065347.input_24.value)

    form_31641713065347.input_21.value = eval(document.form_31641713065347.input_61.value) * eval(document.form_31641713065347.input_27.value)

    form_31641713065347.input_46.value = eval(document.form_31641713065347.input_62.value) * eval(document.form_31641713065347.input_45.value)

    form_31641713065347.input_32.value = eval(document.form_31641713065347.input_25.value) + eval(document.form_31641713065347.input_26.value) + eval(document.form_31641713065347.input_21.value) + eval(document.form_31641713065347.input_46.value) +

    eval(document.form_31641713065347.input_30.value)

    }

    </script>

     <link type="text/css" rel="stylesheet" target="_blank" href="http://jotformeu.com/css/styles/buttons/form-submit-button-black_blue.css?3.1.797" rel="nofollow noopener"/>

    <form class="jotform-form" action="http://submit.jotformeu.com/submit/31641713065347/" method="post" name="form_31641713065347" id="31641713065347" accept-charset="utf-8">

      <input type="hidden" name="formID" value="31641713065347" />

      <div class="form-all">

        <ul class="form-section">

          <li class="form-line form-line-column" id="id_40">

            <div id="cid_40" class="form-input-wide">

              <div id="text_40" class="form-html">

                <p><span style="font-size: large;"><strong>

                      Nota de Encomenda

                    </strong></span>

                </p>

              </div>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_41">

            <label class="form-label-top" id="label_41" for="input_41"> Data: </label>

            <div id="cid_41" class="form-input-wide"><span class="form-sub-label-container"><input class="form-textbox" id="day_41" name="q41_data[day]" type="tel" size="2" maxlength="2" value="17" /><span class="date-separate">&nbsp;/</span>

                <label class="form-sub-label" for="day_41" id="sublabel_day"> Dia </label></span><span class="form-sub-label-container"><input class="form-textbox" id="month_41" name="q41_data[month]" type="tel" size="2" maxlength="2" value="06" /><span class="date-separate">&nbsp;/</span>

                <label class="form-sub-label" for="month_41" id="sublabel_month"> Mês </label></span><span class="form-sub-label-container"><input class="form-textbox" id="year_41" name="q41_data[year]" type="tel" size="4" maxlength="4" value="2013" />

                <label class="form-sub-label" for="year_41" id="sublabel_year"> 1989 </label></span><span class="form-sub-label-container"><img alt="Escolha uma data" id="input_41_pick" src="//cdn.jotfor.ms/images/calendar.png" align="absmiddle" />

                <label class="form-sub-label" for="input_41_pick"> &nbsp;&nbsp;&nbsp; </label></span>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_33">

            <label class="form-label-top" id="label_33" for="input_33">

              Nome ou Designação:<span class="form-required">*</span>

            </label>

            <div id="cid_33" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_33" name="q33_nomeOu33" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_37">

            <label class="form-label-top" id="label_37" for="input_37">

              Nº de Contribuinte:<span class="form-required">*</span>

            </label>

            <div id="cid_37" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required, Numeric]" data-type="input-textbox" id="input_37" name="q37_nDe37" size="12" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_34">

            <label class="form-label-top" id="label_34" for="input_34">

              O seu E-mail:<span class="form-required">*</span>

            </label>

            <div id="cid_34" class="form-input-wide">

              <input type="email" class=" form-textbox validate[required, Email]" id="input_34" name="q34_oSeu34" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_35">

            <label class="form-label-top" id="label_35" for="input_35">

              Morada (Rua e Código Postal):<span class="form-required">*</span>

            </label>

            <div id="cid_35" class="form-input-wide">

              <textarea id="input_35" class="form-textarea validate[required]" name="q35_moradarua" cols="55" rows="2"></textarea>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_57">

            <label class="form-label-top" id="label_57" for="input_57">

              O E-mail da Loja:<span class="form-required">*</span>

            </label>

            <div id="cid_57" class="form-input-wide">

              <input type="email" class=" form-textbox validate[required, Email]" id="input_57" name="q57_oEmail" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_38">

            <label class="form-label-top" id="label_38" for="input_38">

              Código de Apostas (Loja):<span class="form-required">*</span>

            </label>

            <div id="cid_38" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_38" name="q38_codigoDe" size="20" />

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_36">

            <label class="form-label-top" id="label_36" for="input_36">

              Mensagem:<span class="form-required">*</span>

            </label>

            <div id="cid_36" class="form-input-wide">

              <textarea id="input_36" class="form-textarea validate[required]" name="q36_mensagem36" cols="60" rows="6">Solicito os artigos abaixo discriminados e declaro que, nos termos do regulamento dos "Leilões THANKYOU", se eu fizer acertos no leilão a factura deve ser emitida já com os descontos. E se o valor dos prémios ultrapassar o valor da encomenda, desejo receber a factura gratuita em separado, para poder levantar o seu valor em produtos na loja onde efectuei o jogo e dentro do prazo estipulado.</textarea>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_58">

            <label class="form-label-top" id="label_58" for="input_58">

              Quantidade:<span class="form-required">*</span>

            </label>

            <div id="cid_58" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_58" name="q58_quantidade" size="3" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_5">

            <label class="form-label-top" id="label_5" for="input_5">

              Referência do Produto:<span class="form-required">*</span>

            </label>

            <div id="cid_5" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_5" name="q5_referenciaDo" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_19">

            <label class="form-label-top" id="label_19" for="input_19">

              Preço Unitário (€):<span class="form-required">*</span>

            </label>

            <div id="cid_19" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required, Numeric]" data-type="input-textbox" id="input_19" name="q19_precoUnitario19" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_25">

            <label class="form-label-top" id="label_25" for="input_25">

              Valor (€):<span class="form-required">*</span>

            </label>

            <div id="cid_25" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required, Numeric]" data-type="input-textbox" id="input_25" name="q25_valor" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_59">

            <label class="form-label-top" id="label_59" for="input_59">

              Quantidade 2:<span class="form-required">*</span>

            </label>

            <div id="cid_59" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_59" name="q59_quantidade259" size="3" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_23">

            <label class="form-label-top" id="label_23" for="input_23"> Referência do Produto 2: </label>

            <div id="cid_23" class="form-input-wide">

              <input type="text" class=" form-textbox" data-type="input-textbox" id="input_23" name="q23_referenciaDo23" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_24">

            <label class="form-label-top" id="label_24" for="input_24"> Preço Unitário 2 (€): </label>

            <div id="cid_24" class="form-input-wide">

              <input type="text" class=" form-textbox validate[Numeric]" data-type="input-textbox" id="input_24" name="q24_precoUnitario24" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_26">

            <label class="form-label-top" id="label_26" for="input_26"> Valor 2 (€): </label>

            <div id="cid_26" class="form-input-wide">

              <input type="text" class=" form-textbox validate[Numeric]" data-type="input-textbox" id="input_26" name="q26_valor2" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_61">

            <label class="form-label-top" id="label_61" for="input_61">

              Quantidade 3:<span class="form-required">*</span>

            </label>

            <div id="cid_61" class="form-input-wide">

              <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_61" name="q61_quantidade3" size="3" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_28">

            <label class="form-label-top" id="label_28" for="input_28"> Referência do Produto 3: </label>

            <div id="cid_28" class="form-input-wide">

              <input type="text" class=" form-textbox" data-type="input-textbox" id="input_28" name="q28_referenciaDo28" size="30" />

            </div>

          </li>

          <li class="form-line form-line-column" id="id_27">

            <label class="form-label-top" id="label_27" for="input_27"> Preço Unitário 3 (€): </label>

            <div id="cid_27" class="form-input-wide">

              <input type="text" class=" form-textbox validate[Numeric]" data-type="input-textbox" id="input_27" name="q27_precoUnitario" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column" id="id_21">

            <label class="form-label-top" id="label_21" for="input_21"> Valor 3 (€): </label>

            <div id="cid_21" class="form-input-wide">

              <input type="text" class=" form-textbox validate[Numeric]" data-type="input-textbox" id="input_21" name="q21_valor3" size="6" onkeyup="somar();"><br>

            </div>

          </li>

          <li class="form-line form-line-column form-line-column-clear" id="id_62">

            <label class="form-label-top" id="label_62" f

  • Profile Image
    sidharth_kch
    Answered on June 18, 2013 at 07:09 AM

    @testes1

    I am sorry but calculations are not possible within JotForm editor. You have to download your form's source code and add custom code for calculations.

    Do you want us to look into your code and see why it'd not working? Please explain us your exact requirement.

    Thanks,

    Sidharth

  • Profile Image
    testes1
    Answered on June 18, 2013 at 11:35 AM

    Thanks but I do not need anything, what I wanted was to collaborate and teach users to do calculations in JotForm forms.

     

    Is there somewhere in the forum to put ideas and projects already made ​​to help users?

  • Profile Image
    sidharth_kch
    Answered on June 18, 2013 at 11:44 AM

    @testes1

    Okay got it. 

    Actually, forum post is the best available way for users.

    Thanks,

    Sidharth