Can i pre select a radio button on a form

  • Profile Image
    marsupial
    Asked on July 18, 2011 at 11:46 PM

    I am working with a website which presents the user with 5 different pictures, each picture is a link that will take the user to the form page, is it possible to use 5 radio buttons on the form and pre-select the first one if the user clicked on the first picture, the second one if the user clicked on the second picture and so on?

  • Profile Image
    NeilVicente
    Answered on July 19, 2011 at 12:24 AM

    Hi,

    This can be made possible by appending query strings to the url in the image links.

    First, preview your form in a new tab by clicking the Preview button (while in edit mode) then click Open in New Tab

     

    Then, right click on your form then click View Source/View Page Source. In the source code of your form, find the text input type="radio" then look up the value of the name property of that input.

    In the case of this form, the name of the radio input is "q1_choose" but we will only take "choose".

     

    After getting the input name, append to the url a question mark, followed by the input name, an equals sign, and the value that you want to pre-select

    For example:

    https://www.jotform.com/form/11991127612?choose=Option 3

    https://www.jotform.com/form/11991127612?choose=Option 1

    https://www.jotform.com/form/11991127612?choose=Option 2


    You can then insert the url's you created into each image links in your page.

    Hope you find this post useful. Let us know if you're having any difficulties implementing this solution. Thanks!


    Neil

  • Profile Image
    marsupial
    Answered on July 19, 2011 at 12:30 AM

    Really useful answer, thats exactly what I needed.

    By the way, your service seems to be great, I just joined today and it looks like I will be using it a lot.

    Thank you for your help!!!

  • Profile Image
    NeilVicente
    Answered on July 19, 2011 at 12:52 AM

    You're very much welcome. Hope you find the features we provide most suitable to your needs.

    Anyway, if you have more than 1 field to pre-select/pre-populate, you can do so by joining the two query strings by an ampersand &

    For example:

    http://www.jotform.com/form/11991127612?choose=Option 2&loremIpsum=Dolor


    Have a great day!


    Neil

  • Profile Image
    marsupial
    Answered on July 19, 2011 at 01:04 AM

    Thank you again and you have a great day too!!!

  • Profile Image
    riatech
    Answered on November 04, 2011 at 05:29 PM

    Hi,

    Senario :if i put 3 link / banner in a website. I also embeded jotform into the same website.

    Can i preselect option1 when user click link1. option2 when user click link2...so on..

    Can it be done?

    Thanks.

  • Profile Image
    abajan
    Answered on November 04, 2011 at 06:09 PM

    Yes, that can be done. It's basically the same procedure outlined above by my colleague Neil. Just let us know the forms to which you are referring, the pages in which they're embedded, which fields in the said forms are to be pre-selected and which selections are to be pre-selected. (If you would prefer not to publicize the forms on this forum, we can set the thread to private and show you how the links to the forms should be edited.)

  • Profile Image
    riatech
    Answered on February 25, 2012 at 09:03 PM

    Hi! The question is about pre-select an option.

    How about pre key in data to the form.

    Lets say, i have a ID field.. when user click a link.. the ID field will pre key in with the an value.

    Such as, if a user click link is from website AAAA.com , then the value is AAAA

    if the user click link is from BBB.com , then the value is BBB.

    Is that possible?

    Thanks

  • Profile Image
    liyam
    Answered on February 27, 2012 at 12:29 PM

    If you have control to the referring link, you can probably alter the code of the href with a specific value.

    example: Let's say you have the field in your form called 'url', you can then try to edit your referring link to something like this:

    <a target="_blank" href="jotform.com/form/12345?url=google">link here</a>

    This way, your URL field will then be pre-filled with the value google.

    If you don't have control over the referring URL, you can try using PHP server side scripting.  Here is a sample code for getting the URL referrer using PHP:

    $ext = @substr($_SERVER['HTTP_REFERER'];, (@strrpos($_SERVER['HTTP_REFERER'];, ".") ? @strrpos($_SERVER['HTTP_REFERER'];, ".") + 1 : @strlen($_SERVER['HTTP_REFERER'];)), @strlen($_SERVER['HTTP_REFERER'];));
    $fn = basename($_SERVER['HTTP_REFERER'];,$ext);
    $fn= substr($fn, 0, strlen($fn) -1);

    Now, place the $fn variable in your field's value like this:

         <input type="text" ... value="<?php echo $fn; ?>" />

    Or you can try using URL parameters if you are using the javascript embed code:

        <script type="text/javascript" src="//www.jotform.com/jsform/12345?url=<?php echo $fn; ?>"></script>

    Just let us know if you need assistance or further understanding on this matter.