What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How can I retrieve word count from a "text area" for calculation?

    Asked by DEENSP on November 29, 2014 at 02:10 AM

    I need a simple form to process word count from a text area and then multiply this amount by a rate per word amount (e.g. 0.10, 0.12) so that the total amount in US Dollars can be paid via PayPal using JotForm and PayPal Standard Checkout.  Please check the online form http://form.jotform.co/form/43305638531856 and the screenshot with the required functionality.  Can this be implemented in JotForm?

    Thanks

    GM

    Page URL:
    http://form.jotform.co/form/43305638531856

    Screenshot
    count retrieve online form JotForm word count
  • Profile Image
    JotForm Support

    Answered by EltonCris on November 29, 2014 at 07:42 AM

    Hi,

    Unfortunately, we do not have that functionality in the form builder. We only have entry limits on text areas. Example:

    However, I'm sure you can achieve that when you use your form source code and apply custom javascript that performs the text area word count. Here's an example script that should help.

    <script>

    $('input_3').onchange = $('input_3').onkeyup = function(){

      s = $('input_3').value; 

      s = s.replace(/(^\s*)|(\s*$)/gi,"");

      s = s.replace(/[ ]{2,}/gi," ");

      s = s.replace(/\n /,"\n");

      $('input_4').value = s.split(' ').length; 

    }

    // input_3 must be your textarea field ID.

    // replace input_4 with the textbox ID you want to populate the result.

    </script>

    If you need help with the implementation of this script, let us know.

    Have a good day!

  • Profile Image

    Answered by DEENSP on November 29, 2014 at 01:53 PM

    Hi Elton,

    Indeed I would need help to implement this simple form.  Will it have any cost if you can implement it for me?  It would be easier if I could edit the HTML source from JotForm and not outside.  Please advice.

     

    Best regards

    GM

  • Profile Image
    JotForm Support

    Answered by Charlie on November 29, 2014 at 08:42 PM

    Hi,

    I'm currently making a workaround with the code that my colleague Elton has, let me just finish it and I'll get back to you if it works in my end. Although, please do take note that the changes will apply on the form's source code and you will need to embed it on your website.

    Thank you.

  • Profile Image

    Answered by DEENSP on November 29, 2014 at 09:21 PM
    New response receivedHi Charlie,
    Thank you for your reply on this topic. I would like to have this form working on my website. I have created another Form http://form.jotform.co/form/43321050619849 which is currently working but it is not the Form that I need for unlimited text input and calculation. I have also integrated the PayPal functionality all within JotForm and no extra coding.
    I would greatly appreciate it if you can add the word count and PayPal payment to the source code so that I can embed it on my webpage. My PayPal email is geodirect@yahoo.com
    Best regards,
    GM
    ...
  • Profile Image
    JotForm Support

    Answered by jonathan on November 30, 2014 at 05:09 AM

    Hi GM,

    I suggest you finalize first your jotform that you want to have unlimited text input and Paypal payment integration.

    After you have completed creating the form in your Form Builder, inform us here so that we can proceed with the custom solution needed for the word count calculation. 

    Thanks.

  • Profile Image
    JotForm Support

    Answered by EltonCris on December 01, 2014 at 01:43 PM

    @DEENSP

    Here's the script for this form http://form.jotform.co/form/43321050619849. Just take the source code of this form on the from builder, append the following script to it and you're ready to embed it anywhere you want.

    <script>

    $('input_8').onchange = $('input_8').onkeyup = function(){

      s = $('input_8').value; 

      s = s.replace(/(^\s*)|(\s*$)/gi,"");

      s = s.replace(/[ ]{2,}/gi," ");

      s = s.replace(/\n /,"\n");

        $('input_16_donation').value = ((s.split(' ').length) * 0.12).toFixed(2);

    }

    </script>

    By the way, there's no need for the subtotal field as I have output the calculation result directly on the Paypal field, unless you will require it.

    It should work like the following:

    https://shots.jotform.com/elton/calculate_466451.html

    If you need further assistance, let us know. Thanks!

  • Profile Image

    Answered by DEENSP on December 01, 2014 at 03:21 PM
    New response receivedHi Elton,
    Thank you for the script. I will integrate it to the source code of my Form and see how it works. I will tell you when it is done.
    Best regards,
    GM
    ...
  • Profile Image

    Answered by Ben on December 01, 2014 at 03:56 PM

    Hi,

    Great. Do let us know how it goes. :)

    Best Regards,
    Ben

  • Profile Image

    Answered by DEENSP on December 02, 2014 at 05:01 PM

    New response receivedHi EltonCris,
    Your scripts did not work well within my Form code. In a simple form, it does not input the calculated value in the textbox and on another form it does not direct to the PayPal checkout. I am attaching the links to the forms from my website server. Simple form to calculate word count http://www.deensp.com/desquicktrans2.html and the other with PayPal integration http://www.deensp.com/desquicktrans3.html No word count data is added in the textbox upon submission. I am also attaching the files with the codes. Please check them out and tell what is not in place.
    Regards,
    GM
    ...

  • Profile Image
    JotForm Support

    Answered by EltonCris on December 03, 2014 at 09:41 AM

    @DEENSP

    Place the script right after the ending form tag </form>, that should correct it.

    Thanks!

  • Profile Image

    Answered by DEENSP on December 03, 2014 at 05:12 PM

    HI,

    I have added the script in the specified place and it seems to work now for my Form.  From your first code I added a new variable to calculate the word count and display below the Textarea.

    Upon pressing the Submit button it directs me to the PayPal area but I do not receive an email with the submitted data.  My question is, will it send the submitted data to my email after payment with PayPal?

    Here is the link to the Form: http://www.deensp.com/desquicktrans.html

    Best regards,

    GM

  • Profile Image

    Answered by Ben on December 03, 2014 at 06:18 PM

    Hi,

    I am glad that Elton's code and suggestions worked for you.

    Now in regards to your second question, since it is not related to this thread and its issue, I have moved it to a new thread where we will be replying to you shortly.

    You can find it here: http://www.jotform.com/answers/469041.

    Best regards,
    Ben