locked
how do i restrict users from voting the same item twice in MS Sharepoint / vote 10 out of 20 without repeating vote. RRS feed

  • Question

  • Hi,

     Im doing this voting system to select 10 committee members out of 20 nominees.

    There are few options available (listdown, checkbox etc) but how do I restrict voters from voting the same person twice?

    I tried using checkbox with 20 names, but voters can select all 20, not just 10. Any options to limit to 10 checks?

    Or, if I use radio button or listdown; and listing 20 names in each questions (10 questions), voters can still vote the same 1 person >1 times.

     

    Any solution?

     

    Thanks.

    Thursday, November 17, 2011 3:20 AM

Answers

  • Hi hailmunan,

     

    For your requirement, it can be meet by JavaScript or C#.  you can avoid the submit for the data in C#, like Event Handler,  or you can write some javascript, just as following:

    <script language=JavaScript> var max_count=2;
    var clickedData=new Array(false,false,false,false);
    function itemsClicked(){var i=0;for(var j=0;j<clickedData.length;j++)i+=clickedData[j]?1:0;return(i);}
    function itemClicked(t)
    {
    var check_this=true;
    var x=itemsClicked();
    if (x>=max_count && !clickedData[t])
    {
    check_this=false;
    }
    else
    {
    clickedData[t]=clickedData[t]?false:true;
    eval("document.test.check"+t+".clicked=false;");
    }
    return (check_this);
    }
    </script>
    <form name=test>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <INPUT name=check1 type=checkbox value=Charity_profile onclick="return itemClicked(1)"> Item 1
    <INPUT name=check2 type=checkbox value=lost_found onclick="return itemClicked(2)"> Item 2
    <INPUT name=check3 type=checkbox value=fun_section onclick="return itemClicked(3)"> Item 3
    <INPUT name=check4 type=checkbox value=contacts onclick="return itemClicked(4)"> Item 4
    </form>

    http://www.itechies.net/tutorials/jscript/jsexample.php-pid-check-limit.htm

    Tuesday, November 22, 2011 8:05 AM

All replies

  • Hi hailmunan,

     

    For your requirement, it can be meet by JavaScript or C#.  you can avoid the submit for the data in C#, like Event Handler,  or you can write some javascript, just as following:

    <script language=JavaScript> var max_count=2;
    var clickedData=new Array(false,false,false,false);
    function itemsClicked(){var i=0;for(var j=0;j<clickedData.length;j++)i+=clickedData[j]?1:0;return(i);}
    function itemClicked(t)
    {
    var check_this=true;
    var x=itemsClicked();
    if (x>=max_count && !clickedData[t])
    {
    check_this=false;
    }
    else
    {
    clickedData[t]=clickedData[t]?false:true;
    eval("document.test.check"+t+".clicked=false;");
    }
    return (check_this);
    }
    </script>
    <form name=test>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <INPUT name=check1 type=checkbox value=Charity_profile onclick="return itemClicked(1)"> Item 1
    <INPUT name=check2 type=checkbox value=lost_found onclick="return itemClicked(2)"> Item 2
    <INPUT name=check3 type=checkbox value=fun_section onclick="return itemClicked(3)"> Item 3
    <INPUT name=check4 type=checkbox value=contacts onclick="return itemClicked(4)"> Item 4
    </form>

    http://www.itechies.net/tutorials/jscript/jsexample.php-pid-check-limit.htm

    Tuesday, November 22, 2011 8:05 AM
  • hi, thanks! good one.

     

    but where and do i put the codes?

     

    I am using this company provided sharepoint site. (I don’t own this sharepoint server). I believe I have restricted access to edit certain things on this site. I don’t own the server. But to this site (internally they call it CoP) I have full control over it.

     

    thanks.


    • Edited by hailmunan Wednesday, November 30, 2011 2:28 AM
    Wednesday, November 30, 2011 2:22 AM
  • hi,

     

    Just add a Content Edit webpart to the Vote page, and write the Javascript code there.

    How to use Contetn Editor Web part:http://sptwentyten.wordpress.com/2010/08/31/insert-javascript-into-a-content-editor-web-part-cewp/

    of course, you can also add the javascript code using SharePoint Designer 2010.

     

    Wednesday, November 30, 2011 2:29 AM
  • hi,

     

    i am not sure which version i am using, but in the tutorial it seems all different. can u assist me whre can/should i edit and add the code?

     

    thanks,

    Wednesday, November 30, 2011 2:44 AM
  • hi,

    i believe i am using the latter version of sharepoint (2003?) where the tutorial seems all not familiar in the page.

     

    can u guide me how / where to put the html in the pages?

     

    thanks.

    • Edited by hailmunan Wednesday, November 30, 2011 2:54 AM
    Wednesday, November 30, 2011 2:44 AM