Can I require a client choose two (and only two) checkboxes out of 5 options?

  • Profile Image
    impact100baldwincounty
    Asked on October 02, 2012 at 01:28 AM

    I have a ballot where the user is supposed to vote for two of the five options. Can I do that in JotForm?

  • Profile Image
    danieldlopezp
    Answered on October 02, 2012 at 03:50 AM

     

    There is no “Magic button” to do it jet. But of course it is possible with JotForm

    You are asking how to do it with check boxes but actually in your website you have Radio Buttons.

    This is the method how to do it with Check boxes so you will have to make first some changes in your form to make it works. You need to change the Radio Buttons for Check Boxes and you need to add all the options in just one check box with different options (in your case 5 options)

    After this you should do:

    1.       You need to download the code of your form. How?

    To place the form on your own web page:

    ·         Click Edit your form

    ·         Click Embed Form

    ·         An Embed form wizard will appear, select Source


    ·         Copy the code on the next slide and paste it on your own web page.

     


     You have to download all the files compressed

    2.       Open your HTML page and add this in you header tag (exactly AFTER  <head> )

     

     

    1.       

    <script type="text/javascript">

     

    /***********************************************

    * Limit number of checked checkboxes script- by JavaScript Kit (www.javascriptkit.com)

    * This notice must stay intact for usage

    * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more

    ***********************************************/

     

    function checkboxlimit(checkgroup, limit){

        var checkgroup=checkgroup

        var limit=limit

        for (var i=0; i<checkgroup.length; i++){

            checkgroup[i].onclick=function(){

            var checkedcount=0

            for (var i=0; i<checkgroup.length; i++)

                checkedcount+=(checkgroup[i].checked)? 1 : 0

            if (checkedcount>limit){

                alert("You can only select a maximum of "+limit+" checkboxes")

                this.checked=false

                }

            }

        }

    }

    </script>

    2.       Please insert this code just right after the closing form tag ( exactly AFTER </form>)

     

    <script type="text/javascript">

    //Syntax: checkboxlimit(checkbox_reference, limit)

    checkboxlimit(document.forms['YYYYYYYYYYYY']['XXXXXXXXXX'], 2)

      </script>

     

     

    and you are done!!!!

    In the part XXXXXXXXX you should add the name of the checkbox can be something like: q13_2Which[]

    In the part YYYYYYYY you should add the name of your form, I think in your case is form_12261436139, but I am not sure if this is the right form.

     

    Please try that if you need some assistance let us know and we will help you with this

    Thanks for using Jotform

     

     

  • Profile Image
    impact100baldwincounty
    Answered on October 02, 2012 at 01:11 PM

    Where do I enter the code you provided? When I view source code from my browser, it is not editable.

     

    Here is my ballot form, which does use checkboxes: http://www.jotform.com/?formID=22751140274143

    I do not want to post the form on my website, as only members are allowed to vote and my website does not have member login. 

    My plan is to place this RSVP form on my website:http://form.jotform.us/form/22748800370149

    When a member indicates she wishes to vote online, (which appears after they indicate regrets)  then I would like to be able to send a link to the ballot form.

  • Profile Image
    NeilVicente
    Answered on October 02, 2012 at 01:17 PM

    @impact100baldwincounty

    My colleague's solution requires the form's full source codes to be modified and embedded in a webpage outside JotForm. This is because we do not allow custom scripts to be saved onto a form, for security reasons.

    The form will work as per your requirement. It's just that it will need to be embedded on a page of your site.

    If you need further assistance, let us know and we'll be more than glad to help.