Results 1 to 2 of 2
  1. #1
    HUIEE is offline Member
    Join Date
    Mar 2017
    Posts
    1
    Rep Power
    0

    Exclamation Lucky Draw - exclude drawn name

    Hi all,
    i have downloaded a simple lucky draw software, i have edit little bit, but i not sure how to exclude the name been drawn, so it will not appear in the next draw. Please help. thanks.


    function TrimString(sInString) {
    sInString = sInString.replace( /^\s+/g, "" );// strip leading
    return sInString.replace( /\s+$/g, "" );// strip trailing
    }

    function parseList(textarea) {
    var list_str = $(textarea).val();
    //var Array =
    var names = ["001 Amy", "002 BOB", "003 Cathy"];


    var list_lines = list_str.split("\n");
    for (var i = 0; i < list_lines.length; i++) {
    var name = TrimString(list_lines[i]);
    if (name != "") names.push(name);
    }

    return names;
    }

    $(document).ready(function() {
    var t;

    function startRolling() {
    var names = $("#name_list").data('names');
    var start_idx = $("#name_list").data('start_idx');

    var idx_1 = start_idx % names.length;
    var idx_2 = (start_idx + 1) % names.length;
    var idx_3 = (start_idx + 2) % names.length;
    var idx_4 = (start_idx + 3) % names.length;
    var idx_5 = (start_idx + 4) % names.length;
    $("#draw-1 .text").text(names[idx_1]);
    $("#draw-2 .text").text(names[idx_2]);
    $("#draw-3 .text").text(names[idx_3]);
    $("#draw-4 .text").text(names[idx_4]);
    $("#draw-5 .text").text(names[idx_5]);

    $("#name_list").data('start_idx', idx_2);
    }

    $("#switch").button();
    $("#switch").data("status", "stopped");
    $("#switch").data("origin_text", $("#switch").text());
    $("#switch").click(function(){
    if ($("#switch").data("status") == "stopped") {
    $("#switch").data("status", "rolling");

    $("#switch").text("STOP!");

    names = parseList("#name_list");
    $("#name_list").data('names', names);
    $("#name_list").data('start_idx', 0);

    intervalID = setInterval(startRolling, 80);


    } else {
    clearInterval(intervalID);
    $("#switch").data("status", "stopped");
    $("#switch").text($("#switch").data("origin_text") );


    }

    });
    });
    Attached Files Attached Files

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,989
    Rep Power
    32

    Default Re: Lucky Draw - exclude drawn name

    Javascript != java

    Moved from java section
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Stock Program, exclude
    By Avey in forum New To Java
    Replies: 6
    Last Post: 11-18-2012, 11:26 PM
  2. swt: GridData.exclude in Draw2d?
    By sanchau_in in forum SWT / JFace
    Replies: 0
    Last Post: 05-31-2012, 12:14 PM
  3. Exclude character
    By ZeCute in forum New To Java
    Replies: 2
    Last Post: 05-23-2011, 08:19 PM
  4. Replies: 4
    Last Post: 03-31-2011, 01:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •