How to make a condition that if the form is opened on a mobile device, show something

  • Profile Image
    SCARHS
    Asked on February 14, 2017 at 06:23 PM

    Hi support,

    Would there be anyway to detect when the form is loaded on mobile so I could make a conditional logic out of it
    IE.: showing a picture when A)user is on mobile B)User has answered a specific question on the form.

     

    Let me know thank you.

  • Profile Image
    EltonCris
    Answered on February 15, 2017 at 12:26 AM

    I could not find any workaround to achieve this in the form builder alone.

    But you can achieve this when you use your form source code.

    http://www.jotform.com/help/104-How-to-Download-a-Source-Code-of-your-Form

    And inject custom script in the source code that would fill a value in a specific field when the form is opened on mobile. And then you can use the filled value as the trigger point for your mobile condition.

    You can find sample script from this article http://stackoverflow.com/questions/11381673/detecting-a-mobile-browser.

    If you need further help on this, let us know.

    Regards!

  • Profile Image
    SCARHS
    Answered on February 15, 2017 at 09:08 PM

    If I understand correctly, I would need to inject javascript code into my form to fill a certain field. 

    How do I inject code into my form? Would I need my own website with iframe to do that?

     

    Thank you.

  • Profile Image
    Chriistian
    Answered on February 16, 2017 at 02:34 AM

    Yes you need to inject JavaScript code into your form by downloading the source code as suggested by my colleague. After downloading the source code of your form, you need to open it to a text editor like Notepad and then inject the JavaScript. 

    Would I need my own website with iframe to do that?

    You need to host your form's code to your own server to display the form with injected code. We recommend you to look for freelancers that can help you set this up. You can hire either in http://www.upwork.com/ or http://www.freelancer.com/.

    If you need further assistance, please let us know.
    Regards

  • Profile Image
    SCARHS
    Answered on February 16, 2017 at 08:33 AM

    Thank you support, that answered my questions.