Evaluate Options in Dropdown for Unique Selection?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JL

    #1

    Evaluate Options in Dropdown for Unique Selection?

    Does anyone have any ideas on this please?

    I don't know how to evaluate the no-blank selections against each other from
    a form as follows: .

    I have a form with 6 dropdown fields, each containing a selection of 30
    options (the 30 options are the same for each dropdown list).
    The user needs to select 'one of the 30 options' from each dropdown
    selection, but each option they select must be unique (no duplicate
    selections) or it must be left blank.
    E.g. The user can select Option3 within "dropdown1" , but must select a
    different option for the other dropdowns - OR leave them unselected.

    Any help is greatly appreciated...

    JL


  • kaeli

    #2
    Re: Evaluate Options in Dropdown for Unique Selection?

    In article <wvyhc.457$Zr5. 420@newsfe1-gui.server.ntli .net>,
    design4online@T HISBIThotmail.c om enlightened us with...[color=blue]
    > E.g. The user can select Option3 within "dropdown1" , but must select a
    > different option for the other dropdowns - OR leave them unselected.
    >
    > Any help is greatly appreciated...
    >
    > JL
    >
    >
    >[/color]

    I don't suppose they're all in the same order so that the selectedIndex
    would be the same if the option were the same?

    --
    --
    ~kaeli~
    When you choke a smurf, what color does it turn?



    Comment

    • JL

      #3
      Re: Evaluate Options in Dropdown for Unique Selection?

      The dropdown options would be dynamically populated from a database list (so
      would be in the same order for the 6 dropdown menus).

      The option labels would be the "candidate names" and the option value would
      be the "candidate Ids". When submitted, these would be inserted in to a
      database table along with the user's details (as a voting system).

      Could this be done having the list like this?


      "kaeli" <tiny_one@NOSPA M.comcast.net> wrote in message
      news:MPG.1af073 b2d9cfdccc989d9 b@nntp.lucent.c om...
      | In article <wvyhc.457$Zr5. 420@newsfe1-gui.server.ntli .net>,
      | design4online@T HISBIThotmail.c om enlightened us with...
      | > E.g. The user can select Option3 within "dropdown1" , but must select a
      | > different option for the other dropdowns - OR leave them unselected.
      | >
      | > Any help is greatly appreciated...
      | >
      | > JL
      | >
      | >
      | >
      |
      | I don't suppose they're all in the same order so that the selectedIndex
      | would be the same if the option were the same?
      |
      | --
      | --
      | ~kaeli~
      | When you choke a smurf, what color does it turn?
      | http://www.ipwebdesign.net/wildAtHeart
      | http://www.ipwebdesign.net/kaelisSpace
      |


      Comment

      • Joakim Braun

        #4
        Re: Evaluate Options in Dropdown for Unique Selection?

        "JL" <design4online@ THISBIThotmail. com> skrev i meddelandet
        news:wvyhc.457$ Zr5.420@newsfe1-gui.server.ntli .net...[color=blue]
        > Does anyone have any ideas on this please?
        >
        > I don't know how to evaluate the no-blank selections against each other[/color]
        from[color=blue]
        > a form as follows: .
        >
        > I have a form with 6 dropdown fields, each containing a selection of 30
        > options (the 30 options are the same for each dropdown list).
        > The user needs to select 'one of the 30 options' from each dropdown
        > selection, but each option they select must be unique (no duplicate
        > selections) or it must be left blank.
        > E.g. The user can select Option3 within "dropdown1" , but must select a
        > different option for the other dropdowns - OR leave them unselected.
        >
        > Any help is greatly appreciated...
        >
        > JL[/color]

        How about regenerating the dropdowns as new selections are made?
        You have a base set of 30 options, then:
        * Fill first dropdown with all options
        * Fill second dropdown with all options except the one selected in the first
        dropdown
        * Fill third dropdown with all options except what's selected in first and
        second dropdowns, etc.

        When a selection is made, you regenerate all dropdowns "downstream " from the
        one modified.

        Might be a bit slow, but at least the user can't select a nonexistent item.

        Joakim Braun



        Comment

        • kaeli

          #5
          Re: Evaluate Options in Dropdown for Unique Selection?

          In article <Jazhc.529$Zr5. 65@newsfe1-gui.server.ntli .net>,
          design4online@T HISBIThotmail.c om enlightened us with...[color=blue]
          > The dropdown options would be dynamically populated from a database list (so
          > would be in the same order for the 6 dropdown menus).
          >
          > The option labels would be the "candidate names" and the option value would
          > be the "candidate Ids". When submitted, these would be inserted in to a
          > database table along with the user's details (as a voting system).
          >
          > Could this be done having the list like this?
          >
          >[/color]

          It could be done no matter how the list was built, it's just a lot
          easier if the selectedIndex is the same for equal fields.

          I made a little example with 3 selects with 6 options each. Tested in
          IE6. Checks only for duplicates. If you want to make sure there is a
          selection, make sure the first element is a "Select one" type, then
          check for a[i] being equal to 0 as well as being equal to the next a[i+
          1].

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
          "http://www.w3.org/TR/REC-html40/loose.dtd">
          <html>
          <head>
          <title> New Document </title>
          <script type="text/javascript">
          function verify(frm)
          {
          var a = new Array(frm.selec t_1.selectedInd ex,frm.select_
          2.selectedIndex ,frm.select_3.s electedIndex);
          a.sort();
          for(i=0; i<a.length; i++)
          {
          if(a[i]==a[i+1])
          {
          alert("error: duplicates");
          return false;
          }
          }
          return true;
          }
          </script>
          </head>

          <body>
          <form name="f1" onSubmit="retur n verify(this)">
          <select name="select_1" >
          <option value='0'>zero</option>
          <option value='1'>one</option>
          <option value='2'>two</option>
          <option value='3'>three </option>
          <option value='4'>four</option>
          <option value='5'>five</option>
          </select>
          <br>
          <select name="select_2" >
          <option value='0'>zero</option>
          <option value='1'>one</option>
          <option value='2'>two</option>
          <option value='3'>three </option>
          <option value='4'>four</option>
          <option value='5'>five</option>
          </select>
          <br>
          <select name="select_3" >
          <option value='0'>zero</option>
          <option value='1'>one</option>
          <option value='2'>two</option>
          <option value='3'>three </option>
          <option value='4'>four</option>
          <option value='5'>five</option>
          </select>
          <br>
          <input type="submit" value="Submit">
          </form>
          </body>
          </html>

          --
          --
          ~kaeli~
          Never say, "Oops!"; always say, "Ah, interesting!"



          Comment

          • JL

            #6
            Re: Evaluate Options in Dropdown for Unique Selection?

            Hi Kaeli,

            I couldn't get the page to work (nothing happened when I made the same
            selections and pressed submit) - was there something else I needed to do to
            get it to work?

            Thanks
            JL


            | It could be done no matter how the list was built, it's just a lot
            | easier if the selectedIndex is the same for equal fields.
            |
            | I made a little example with 3 selects with 6 options each. Tested in
            | IE6. Checks only for duplicates. If you want to make sure there is a
            | selection, make sure the first element is a "Select one" type, then
            | check for a[i] being equal to 0 as well as being equal to the next a[i+
            | 1].
            |
            | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            | "http://www.w3.org/TR/REC-html40/loose.dtd">
            | <html>
            | <head>
            | <title> New Document </title>
            | <script type="text/javascript">
            | function verify(frm)
            | {
            | var a = new Array(frm.selec t_1.selectedInd ex,frm.select_
            | 2.selectedIndex ,frm.select_3.s electedIndex);
            | a.sort();
            | for(i=0; i<a.length; i++)
            | {
            | if(a[i]==a[i+1])
            | {
            | alert("error: duplicates");
            | return false;
            | }
            | }
            | return true;
            | }
            | </script>
            | </head>
            |
            | <body>
            | <form name="f1" onSubmit="retur n verify(this)">
            | <select name="select_1" >
            | <option value='0'>zero</option>
            | <option value='1'>one</option>
            | <option value='2'>two</option>
            | <option value='3'>three </option>
            | <option value='4'>four</option>
            | <option value='5'>five</option>
            | </select>
            | <br>
            | <select name="select_2" >
            | <option value='0'>zero</option>
            | <option value='1'>one</option>
            | <option value='2'>two</option>
            | <option value='3'>three </option>
            | <option value='4'>four</option>
            | <option value='5'>five</option>
            | </select>
            | <br>
            | <select name="select_3" >
            | <option value='0'>zero</option>
            | <option value='1'>one</option>
            | <option value='2'>two</option>
            | <option value='3'>three </option>
            | <option value='4'>four</option>
            | <option value='5'>five</option>
            | </select>
            | <br>
            | <input type="submit" value="Submit">
            | </form>
            | </body>
            | </html>
            |
            | --
            | --
            | ~kaeli~
            | Never say, "Oops!"; always say, "Ah, interesting!"
            | http://www.ipwebdesign.net/wildAtHeart
            | http://www.ipwebdesign.net/kaelisSpace
            |


            Comment

            • JL

              #7
              Re: Evaluate Options in Dropdown for Unique Selection?

              Hi Joakim,

              Yes - this would be the ideal solution (regenerating the dropdowns as new
              selections are made) but how would I do this?
              Can it be done using ASP at all (rather than client side JavaScript)?
              Anyone know?

              Thanks
              JL


              | How about regenerating the dropdowns as new selections are made?
              | You have a base set of 30 options, then:
              | * Fill first dropdown with all options
              | * Fill second dropdown with all options except the one selected in the
              first
              | dropdown
              | * Fill third dropdown with all options except what's selected in first and
              | second dropdowns, etc.
              |
              | When a selection is made, you regenerate all dropdowns "downstream " from
              the
              | one modified.
              |
              | Might be a bit slow, but at least the user can't select a nonexistent
              item.
              |
              | Joakim Braun


              Comment

              • Michael Winter

                #8
                Re: Evaluate Options in Dropdown for Unique Selection?

                On Wed, 21 Apr 2004 23:04:17 +0100, JL <design4online@ THISBIThotmail. com>
                wrote:
                [color=blue]
                > Yes - this would be the ideal solution (regenerating the dropdowns as new
                > selections are made) but how would I do this?[/color]

                A question, first: do the various SELECT elements have meaning? You said
                that this is for a voting system, so does a candidate in an earlier SELECT
                element have preference over a candidate in a lower element? If so, this
                suggestion wouldn't be a good idea as the user might have trouble changing
                the order of candidates.
                [color=blue]
                > Can it be done using ASP at all (rather than client side JavaScript)?
                > Anyone know?[/color]

                You could submit the page and rewrite it with each selection, but this
                isn't the same effect. Unless order is irrelevant, Kaeli's suggestion is
                the best client-side validation technique.

                Mike

                --
                Michael Winter
                M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

                Comment

                • JL

                  #9
                  Re: Evaluate Options in Dropdown for Unique Selection?

                  Hi,

                  The form is intended to just pick 6 candidates from the 30 available - all
                  six that are selected are of the same hierarchy (it doesn't matter which
                  order they are picked in).

                  Has anyone seen any scripts/applications anywhere for this type of voting
                  system?

                  Thanks all.....

                  JL


                  "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
                  news:opr6t59pem 5vklcq@news-text.blueyonder .co.uk...
                  | On Wed, 21 Apr 2004 23:04:17 +0100, JL <design4online@ THISBIThotmail. com>
                  | wrote:
                  |
                  | > Yes - this would be the ideal solution (regenerating the dropdowns as
                  new
                  | > selections are made) but how would I do this?
                  |
                  | A question, first: do the various SELECT elements have meaning? You said
                  | that this is for a voting system, so does a candidate in an earlier SELECT
                  | element have preference over a candidate in a lower element? If so, this
                  | suggestion wouldn't be a good idea as the user might have trouble changing
                  | the order of candidates.
                  |
                  | > Can it be done using ASP at all (rather than client side JavaScript)?
                  | > Anyone know?
                  |
                  | You could submit the page and rewrite it with each selection, but this
                  | isn't the same effect. Unless order is irrelevant, Kaeli's suggestion is
                  | the best client-side validation technique.
                  |
                  | Mike
                  |
                  | --
                  | Michael Winter
                  | M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)


                  Comment

                  • kaeli

                    #10
                    Re: Evaluate Options in Dropdown for Unique Selection?

                    In article <uaChc.282$I52. 77@newsfe2-gui.server.ntli .net>,
                    design4online@T HISBIThotmail.c om enlightened us with...[color=blue]
                    > Hi Kaeli,
                    >
                    > I couldn't get the page to work (nothing happened when I made the same
                    > selections and pressed submit) - was there something else I needed to do to
                    > get it to work?[/color]

                    Aside from being careful about line breaks, no.
                    You did join the lines after your copy/paste, right? Word-wrap can do
                    bad things.

                    Go here and see if it works.


                    It worked in IE6 and NN7 for me.

                    --
                    --
                    ~kaeli~
                    If it's tourist season, why can't we shoot them?



                    Comment

                    • JL

                      #11
                      Re: Evaluate Options in Dropdown for Unique Selection?

                      Hi Kaeli,

                      Yes - it works now.
                      It looks like this will do the trick and it's such a small code size too!

                      Thank you very, very much....
                      :-)

                      JL



                      "kaeli" <tiny_one@NOSPA M.comcast.net> wrote in message
                      news:MPG.1af189 62249de48e989d9 e@nntp.lucent.c om...
                      | In article <uaChc.282$I52. 77@newsfe2-gui.server.ntli .net>,
                      | design4online@T HISBIThotmail.c om enlightened us with...
                      | > Hi Kaeli,
                      | >
                      | > I couldn't get the page to work (nothing happened when I made the same
                      | > selections and pressed submit) - was there something else I needed to do
                      to
                      | > get it to work?
                      |
                      | Aside from being careful about line breaks, no.
                      | You did join the lines after your copy/paste, right? Word-wrap can do
                      | bad things.
                      |
                      | Go here and see if it works.
                      | http://www.ipwebdesign.net/test4.html
                      |
                      | It worked in IE6 and NN7 for me.
                      |
                      | --
                      | --
                      | ~kaeli~
                      | If it's tourist season, why can't we shoot them?
                      | http://www.ipwebdesign.net/wildAtHeart
                      | http://www.ipwebdesign.net/kaelisSpace
                      |


                      Comment

                      Working...