in

Community Server

The platform that enables you to build rich, interactive communities

Limiting Number of Games Selected

Last post 07-25-2010 4:32 PM by Rob. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-25-2010 5:31 AM

    • RandyR
    • Top 75 Contributor
    • Joined on 09-07-2009
    • Posts 1

    Limiting Number of Games Selected

    Anyone have any suggestions on how I could limit the number of games picked? Rather than selecting everygame I'd like to allow the user to select any 5 games. I suppose I'd need to track the number selected as each is selected and then when the total is reached display your 5 selections have been made and show then. I would then allow the user to accept or redo them.

  • 07-25-2010 4:32 PM In reply to

    • Rob
    • Top 25 Contributor
    • Joined on 08-25-2009
    • Posts 16

    Re: Limiting Number of Games Selected

    I call a javascript function to do this. Each time a radio button is clicked this piece of code is called. If the limit is reached you get the popup message.

    Modify the WeeklyEntry.asp file...
    Declare a local variable to keep count
    dim mylimit 
    mylimit = 5

    Place this piece of code inside each input you want to keep tabs on. e.g. each radio button
    onclick="countChoices(this,this.form,<% =mylimit %>);"

    Place this piece of code somewhere accessible. ie at the bottom of the page of code or in custom.asp You may have to play with the line that reads type=="checkbox" to get it to count radio buttons as i use it to count checkboxes.
    <script language=javascript type="text/javascript">

    function countChoices(oo,ff,imax)
       { //start function

       var oElement = ff.elements, jj = 0;
       for(var icounter=0; icounter<oElement.length; icounter++)
       {  //start first for loop
      if(oElement[icounter].type=="checkbox")
      {
         if(oElement[icounter].checked)
             {
             jj++;
            }
          }//end first for loop
       } // end for loop
       if(jj > imax)
         {
         alert("Sorry. The Joker limit for this week is "+imax+".");
            oo.checked = false;
            return false;
      }
      } //end function
    </script>

     Good luck!

Page 1 of 1 (2 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems