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

    using the calculate function to return the first letter of another field

    Asked by GarvanFlow on February 19, 2014 at 06:02 PM

    Hi All 

    In our organisation we have user emails that are srtuctured in a particular way i.e. "first initial of first name"period"last name"@garvan.org.au.  I want to be able to generate an email address from the first and last name fields. 

    I thought i could use the calculate field function to generate this but it seems you can only use complete fields.

     

    Given this i thought i could create another field (first name letter)  that uses the caluclate based on the first name field to return the first letter of the first name  i.e  

    First name letter 
     {firstName}

    Read Only.
    Wait for input before including the field in calculation.
     

     but is set to only allow 

    SizeSet number of characters users can enter
    1
    ValidationValidate entry format
    None
    Max SizeMaximum allowed characters for this field
    1

    This  didnt seem to work as it fills the first name letter field completely with what ever is entered into the first name field 

     

    Any ideas ?

     

    Cheers 

    Rob

    Page URL:
    http://form.jotformpro.com/form/40228477334960

    Emails email style size name
  • Profile Image
    JotForm Support

    Answered by TitusN on February 19, 2014 at 07:33 PM

    Hello Rob,

    Thank you for contacting us.

    That is not currently possible with Jotform features.

    However, using the form's source code, you are able to extract the first letter of the first name using the JavaScript Slice method.

    I will throw this at my colleagues and see whether we can whip up a demo form.

    Thanks

  • Profile Image

    Answered by GarvanFlow on February 19, 2014 at 07:36 PM

    Hi TitusN  - thanks for your response - i look forward to seeing what your collegues come up with.

     

    Thanks 

  • Profile Image
    JotForm Support

    Answered by TitusN on February 20, 2014 at 06:16 AM

    Hello,

    Here's a demo you might consider that uses a comination of a form's source code and some Javascript using the Slice function:

    https://shots.jotform.com/titus/createemail.html

    Sorry  -it might be a little choppy, so use the Tab key to skip from field to field when filling it out.

    Let us know if this would work for you.

  • Profile Image

    Answered by GarvanFlow on February 23, 2014 at 09:19 PM

    Hi Titus 

    this is exactly what we are after. at the moment i cant get it to work in our website but i think i need to do some work on the Java script integration as we use drupal gardens.

     

    basically what i did was added this part to my form source code in dream weaver  (and changed the field numbers) then copied the full cript and pasted it into the website as a full html. problem was that then noe of the jotform conditions work.

    <script type="text/javascript">
      function getfirstletter(){
      var str = document.getElementById("input_3").value;
      document.getElementById("input_6").value = str.slice(0,1);
      }

    Thanks 

     

    Rob

    </script>

     

     

     

  • Profile Image
    JotForm Support

    Answered by ashwin_d on February 24, 2014 at 01:28 AM

    Hello Rob,

    Please share your web page URL where you have added the form's source code. It seems there must be some code conflict between form's scripts and other scripts of your web page. 

    I would suggest you to please embed your form in an iFrame and that should help you. Here are the steps you should follow:

    1. Download your form's full source code and add the custom JavaScript code.

    2. Upload this html file and all the other folders in your own server and grab the html file URL.

    3. Paste the following iFrame code in your webpage where you want to display your form:

    <iframe id="JotFormIFrame" onload="window.parent.scrollTo(0,0)" allowtransparency="true" src="_____" frameborder="0" style="width:100%; height:100%; border:none;" scrolling="no"></iframe>

    4. Replace the "_____" in the above iFrame code with the html file URL you saved in step number 2 above.

    This will ensure that there is no code conflict and the form work independently. All your form's conditions should work normally.

    Do get back to us if you have any questions. 

    Thank you!

  • Profile Image

    Answered by oztechs on July 07, 2016 at 10:58 PM

    This question was posted back in 2014, can we now extract the first letter of a field nattily using Jotform?
  • Profile Image
    JotForm Support

    Answered by ashwin_d on July 08, 2016 at 03:50 AM

    Hello oztechs,

    I have moved your question to a new thread and you will be answered here:  https://www.jotform.com/answers/878120

    Thank you!