conditional (reducing?) logic

  • Profile Image
    audabee
    Asked on November 29, 2012 at 06:45 PM

    I need people to vote 1, 2, 3 on a bunch (probably about eight) options. But I don't want to be able to vote for the same option twice.

    So, is there a way to have a drop down with say, options 1-8, and if you select option 1, then the second list would only have 2-8?

    thanks!

  • Profile Image
    EduardoMendez
    Answered on November 29, 2012 at 07:24 PM

    Hi there

    Can you please share with me the URL of the form?

    We'll be glad to assist you with this!

  • Profile Image
    audabee
    Answered on November 29, 2012 at 07:32 PM

    Thanks Eduardo.

    It's a "Work in progress" (you'll be able to tell from the images :) at the moment, but this is the first draft:

    http://form.jotform.co/form/23336174946863

  • Profile Image
    abajan
    Answered on November 29, 2012 at 08:16 PM

    @audabee

    It's not possible to do that in the form builder but if a copy of the form's full source is embedded in a web page, we might be able to devise a script to prevent duplicate selections. This one comes close but it's flawed in that one can select duplicate options in reverse: If they are selected in a right to left (or bottom to top, in your form's case) fashion.

    We'll let you know if we come up with anything.

  • Profile Image
    abajan
    Answered on November 29, 2012 at 08:20 PM

    Hang on! I just discovered that it does work in reverse, just in a different way. I'll see how best it can be incorporated into a clone of your form and get back to you.

  • Profile Image
    audabee
    Answered on November 29, 2012 at 10:12 PM

    Ooh, exciting. Cool. Thanks!

  • Profile Image
    abajan
    Answered on November 30, 2012 at 12:47 AM

    Hi again,

    The solution will work for your form but I just want to be certain of the desired functionality. There are only six choices per selector (dropdown) but there are eleven selectors. After six choices are made, nothing else would be able to be selected. So, should I assume that the A and B fields are grouped separately? For instance, if "Mo Four" is selected for "3A..." it cannot be selected in any of the other "A" fields but it can be in one of the "B" fields. Is that correct? Also, if that is the case, in which group does the first dropdown belong?

    I'm going to bed now (it's pretty late here in Barbados) but I'll view your reply in the morning.

    Good Night. (Or should that be Good Morning?!)

  • Profile Image
    abajan
    Answered on November 30, 2012 at 10:23 AM

    @audabee

    Test this demo and let us know if it has the sort of functionality you were seeking. You'll see that if a contestant is chosen in either section ("A" or "B"), he may not be selected again in any other dropdown of that section. The first dropdown ("Manliest Mo - A Mo that Chuck Norris would be proud of") is not included in the said validation. So, if (say) "Mo three" is chosen there, he may be selected again in section "A" and "B".

    Even though the form looks like a clone of yours, it's actually a completely new form. I did that in order for the script in the page to work. (The IDs of the inputs in your form weren't in a sequence that the script's for loops could be edited to target and since field IDs can't be changed in the form builder, the form had to be rebuilt. However, since it's a pretty simple form, the task wasn't as tedious as it may sound.)

    Incidentally, this thread has been set to Private, in case you didn't want to publicize the form on the forum. Currently, only our team can view it. Even those who would have previously viewed it would not now be able to do so, even if they know the URL. In order to access the thread, they would have had to have previously posted to it. So, feel free to discuss the form in detail.

    We look forward to your thoughts on the solution demonstrated. (It would not be too difficult for us to adjust the validation if it's incorrect.)

  • Profile Image
    audabee
    Answered on November 30, 2012 at 01:20 PM

    Wow! Greetings to Barbados from Australia!!! Thank you so much for all that effort. I think I may've made it unduly complicated for you though.

    The A & B series were going to be for me to identify which list had an option missing when I was trying to do it with conditional logic (if you selected One in Chuck Norris, you'd only have Two-Five in "Most creative" but I realised that 1. I couldn't get the logic to make them all to disappear when required and 2. It made the Ned Flanders option a nightmare with all the options it'd require).

    So, I really only need three dropdowns (Chuck, Creative and Ned Flanders) and have the list of numbers (which will be names). Your form seems to do the trick - I couldn't select say, Three if I'd previously selected it. That should work. Although the first example from jsfiddle was good too (although it doesn't cope if you change a selection). I'm happy to go with either.

    No real need to make this private. The form is for the end of Movember (men getting sponsored to grow a moustache to support men's health initiatives) and we're voting for a bit of fun to reward the guys for their hairy efforts :)

    Thank you so much again, abajan. I'm just delighted (and relieved) that you were able to come up with a solution (and a spare!).

    Sue

  • Profile Image
    abajan
    Answered on November 30, 2012 at 09:19 PM

    Hi Sue

    I've updated the demo. Since your form hasn't been used as yet, the simplest way for you to implement the solution would be to do the following:

    1. Clone my form (See: How to Clone a Form from a Web Page)

    2. Edit the field labels and dropdown options as desired. (Just ensure that the options in the three fields are identical)

    3. Embed a copy of the clone's full source code into a web page of your choice

    4. Add this code to the bottom of the same page within which the form is embedded, just before the closing body tag, just like in the source of the demo

    Please let us know how everything turns out and/or if you would like further assistance.


    Wayne

  • Profile Image
    audabee
    Answered on December 02, 2012 at 03:33 PM

    Wayne, thank you again. Sorry I took so long to get back to you.

    I cloned your form, but it seems to have stopped working (could it have stripped out some of the logic?). The "demo" link works, but once it's cloned, the functionality borks.

    Weird?

  • Profile Image
    NeilVicente
    Answered on December 02, 2012 at 03:48 PM

    @audabee

    Wayne's demo is heavily modified with custom codes, and is hosted on an external server because JotForm does not allow saving of custom codes (script).

    With that said, cloning his demo form alone isn't going to make it work. You should follow his instructions to the letter, which also means that the form (source codes) should be embedded on a webpage outside of JotForm.

  • Profile Image
    audabee
    Answered on December 02, 2012 at 10:27 PM

    Ah yes, sorry. I missed a step. 

    It works a treat! Many thanks for all your help, guys. That's great.

  • Profile Image
    abajan
    Answered on December 03, 2012 at 03:55 AM

    Sue,

    We're very glad you got it to work. Should you need assistance with any other JotForm matter, we'd be happy to help.

    Cheers :)


    Wayne