Limiting Choices

  • Profile Image
    Ash
    Asked on January 25, 2012 at 04:55 AM

    Hi, if i had a for with say 20 choices (lets say 20 names) and i want my users to select 10 of those names and submit, is there a way to

     

    1) limit the user to exactly 10 choices, no more, no less and alert them if they try and submit with the wrong noumber

    2) show me the order in which the have selected the names

    3) spread the names across two pages of form

     

     

    thanks

  • Profile Image
    fxr
    Answered on January 25, 2012 at 10:04 AM

    Hello Ashley,

    We may be able to help to with at least some of that functionality. 

    I have noted your email in our inbox earlier. 

    --

    To achieve this you would need to embed full source of your form onto your website, the instructions on how to download a forms source code is here, you would then need to extract the zip archive that you have downloaded and then upload the files and directories to your webserver. 

    Once that is done, give us the URL and we can have a look at providing you with a little javascript / HTML that should hopefully allow you to add this functionality. 

    We cannot promise that we will be able to help you, but we are willing to try. 

  • Profile Image
    zugfrig78
    Answered on January 25, 2012 at 07:08 PM
    Hi I have managed to download the source as required but on the drag and drop website builder (which is weebly) I can create a HTML box but cannot paste any files only code. I have done so to the website www.thepclub.weebly.com but the formate is no longer aligned. All the other files that came in the source download I done know what to do with (eg the folders called CSS and js)
  • Profile Image
    fxr
    Answered on January 25, 2012 at 08:28 PM

    you need to try to get those directories uploaded to your webserver. 

    Do you not have FTP access?

  • Profile Image
    zugfrig78
    Answered on January 25, 2012 at 09:04 PM

    no weebly does not have weebly access

  • Profile Image
    zugfrig78
    Answered on January 25, 2012 at 09:29 PM

    i mean they dont have ftp access.

     

    could the line of script in my original format (the html/php) be reworked and added to your to code

  • Profile Image
    fxr
    Answered on January 26, 2012 at 03:33 AM

    I am working on a solution to this for you.

    Please, like I have already asked, stop posting the same question over and over, its an awful waste of our resources. 

  • Profile Image
    zugfrig78
    Answered on January 26, 2012 at 03:38 AM
    Ok, I promise to sit on my keyboard until I hear back.I've just been so excited reading all these posts and how helpful you guys are with people and my website might finally do what I'd hope it could without me not spending 10 years learning to write script :-)
  • Profile Image
    fxr
    Answered on January 26, 2012 at 12:25 PM

    I have added some javascript to your form here

    Please test its functionality and test it on as many different browsers as possible, just to make sure its working ok. 

    We will then look at how we are going to get it moved onto weebly. 

  • Profile Image
    zugfrig78
    Answered on January 26, 2012 at 07:03 PM

    Hello Fxr,

    I am so glad i decided to be patianet....what you have created is UTTER BRILLIANCE, you have no idea, that is far and beyond what i expected, the way if greys out names down the bottom when you choose names up the top an dhow the 18 counts down as you click them is brilliant........

    I have tried on 3 browsers (at the link you snet) and all work perfectly) then...

    Ok (sorry impatient agian) i uploaded to weebly as first an embedded html and secondly a line to the website (from the jotform builder) and while both show up the same, the reducing of numbers and greying out do not work.... i am guess this is the part that you are saying is javascript????

     

    OK so now i sit here sweating bullets because i have your link in front of me and im seeing the absoulte perfect solution to my website but am shaking like a leaf that weebly will not be able to support it.....

     

    so in answer to your question..... tested on 3 browsers from your link above and it works perefct...now just to get it into weebly

     

    p.s i left them on weebly at http://thepclub.weebly.com/jot-trial.html and http://thepclub.weebly.com/test-page.html

  • Profile Image
    fxr
    Answered on January 26, 2012 at 07:35 PM

    OK, 

    Really happy to hear you like it. 

    There was one issue, I left outstanding, the 'Clear Form' option is working properly because of the alterations made to the form with my javascript.

    I could sit and write some more code to make it work properly, but is it absolutely necessary? Perhaps we could just remove it from the form and possibly look at it on another date?

    I will have a look now at what weebly is doing the javascript.

  • Profile Image
    fxr
    Answered on January 26, 2012 at 07:41 PM

    OK, can you remove that current script embed code, which you say you used a 'HTML box' to add to weebly. 

    Then in a new 'HTML box' , copy and paste the following code:

    (you should be CTRL+A then, CTRL+C to copy it, in its entirety)

    http://pastie.org/pastes/3260130/text

  • Profile Image
    Ash
    Answered on January 26, 2012 at 07:43 PM

    hi,

     

    clear button is not required

  • Profile Image
    Ash
    Answered on January 26, 2012 at 07:49 PM

    ok done and pblished to http://thepclub.weebly.com/jot-trial.html

     

    but still not working

  • Profile Image
    fxr
    Answered on January 26, 2012 at 08:37 PM

    OK remove that code, and try this version instead:

    http://pastie.org/pastes/3260409/text

  • Profile Image
    zugfrig78
    Answered on January 26, 2012 at 08:42 PM

    PURE GENIOUS IT WORKS, IT WORKS!!!!!

     

    ok no the curve ball, i dont want to alter it one bit as far as functionality but, i only used fake names for testing, i will have to go in and input the real players names

     

    can this still be done through jotform online or do i have to change them in each script....

     

    the other thing is i need to reprodcue the exacpt same script 10 times over each with that correspoding teams players names (and that team name on the email notificaition to me....

     

    can this be done?

  • Profile Image
    fxr
    Answered on January 26, 2012 at 09:03 PM

    No, you wont have to edit the actual javascript when changing the players names, but you will have to reembed the source code like you have been doing tonight, after you changing the player names on JotForm. 

    ---

    Probably the easiet way of sorting out that second issue is to clone your existing form, edit/add the relevant player names on each of the clones, then embedding each form onto seperate pages on your website. 

    I probably wont have time to look at this tomorrow, but if you get the 10 cloned forms ready, I will take you through that next week. 

    Just one thing to note:

  • Profile Image
    zugfrig78
    Answered on January 26, 2012 at 09:34 PM

    ok great, thanks, i will get playing...i will still only use fakes names for now beacause squad selection happens in two weeks but that should be fine....

     

    just to wrap up when i get the code to embed in my webpage i am selecting Source code not embed is that correct?

  • Profile Image
    zugfrig78
    Answered on January 26, 2012 at 10:54 PM

    Hi JXR,

     

    OK we are so close.......

    i found cloning quite easy in jotform and i have gone ahead and cloned it 10 times.... one for each team... i have also left your original form untouched as like a safetynet version....

    i have even entered the 45 names in each form so no form is the same, well i actully used the teams players from last year for the test but now i know how easy it is i can change them when the new teams are picked that will be fine

     

    the only issue i have is whenever i try and use either the embedded code or the source code generated by jotform when clicking the blue world icon it displays on screen but like before none of the java parts work

     

    an eample of this can be seen at http://thepclub.weebly.com/practice-page.html

     

    its only when i paste the code from your forum link above that the java parts do work

    the working version you supplied is uploaded at http://thepclub.weebly.com/jot-trial.html 

     

    im not sure why but only the code you supplied in you above link will work when pasted into weebly ....but..... when i click the blue worldle in jotform and copy either the embedded code or source code it generates (evern with your orignial team selection form) it will only display the form without funtioning javascript

     i did some investigating and not that i know much about script language is was plain to me the all 3 (the jotform embeded, jotform source code and your forum posted version all look completely different.

     

    im not sure the forum cuold handle much text but i have emailed them to you to show you what i mean...

     

    like i said the forum version works it just a matter of me being able to get the new code out of jotform after i changes the names.

    i expect this is something small stopping this

  • Profile Image
    m4cl4rk
    Answered on March 16, 2012 at 06:47 PM

    Sweet code. I'd like to hack the js used to limit the choices, so I can use it for a little magic of my own. Where can I crab that from?

  • Profile Image
    fxr
    Answered on March 16, 2012 at 06:53 PM

    The code is here  (its not perfect, but it works ;) )

    It does a few other things; you are probably interested in the checkboxlimit function near the end. 

  • Profile Image
    m4cl4rk
    Answered on March 16, 2012 at 07:23 PM

    Nice. Thanks. I actually only need to limit 16 checkboxes to 4. Any info on how I can hack the code down without completely breaking it? 16 choices, any 4 are picked, the remaining fieds are disabled. I'd like to pop an alert box if someone tries to select more than 4. Thanks for your help.

    :-)

  • Profile Image
    fxr
    Answered on March 16, 2012 at 07:48 PM

    You should be able to that by dropping this javascript function in between two script tags:

     

    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

    }

    }

    }

    }

     

     

     

    Then enable the functionality by using this:

    //Syntax: checkboxlimit(checkbox_reference, limit)

    e.g

    checkboxlimit(document.forms.formname.checkboxgroupname, 4)

     

    Its hard to give precise code, but hacking something together from that should be straightforward enough.

  • Profile Image
    m4cl4rk
    Answered on March 16, 2012 at 08:29 PM

    Sweet. Thank you.