Results 1 to 2 of 2

Thread: Make selection based on number

  1. #1
    Join Date
    Oct 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Make selection based on number

    I'm trying to build a ncaa bracket page. What I want to do is have the two teams with a score box next to it, after the user inputs the score the script selects the next round winner, and same with the next round.

    Example:
    Duke 66
    Wake Forest 57

    Automatically inputs Duke to the next round.

    This is what I have so far:

    --------------------------------------------------
    Code:
    <script type="text/javascript" language="javascript">
    function GetScore()
    {
    scorea=document.getElementById("scorea");
    scoreb=document.getElementById("scoreb");
    
    if (scorea.value > scoreb.value) {
    results.value=1;
    }
    if (scoreb.value > scorea.value) {
    results.value=2;
    }
    }
    </script>
    
    Duke:<input name="scorea" type="text" id="scorea" onChange="GetScore()" size="1" maxlength="2">
    Wake Forest:<input name="scoreb" type="text" id="scoreb" onChange="GetScore()" size="1" maxlength="2">
    --------------------------------------------------

    and I can get it to work if the results field is a text field and inputs a number. Ideally, it would populate a drop down or a text field with text. Like if the code below worked, but I'm a js newbie. So obviously it's wrong. But what the finished script needs to do is work in multiple rounds. After the first round there are subsequent rounds based on the winners of the first. So:

    --------------------------------------------------
    Code:
    <script type="text/javascript" language="javascript">
    function GetScore()
    {
    scorea=document.getElementById("scorea");
    scoreb=document.getElementById("scoreb");
    scorec=document.getElementById("scorec");
    scored=document.getElementById("scored");
    scoree=document.getElementById("scoree");
    scoref=document.getElementById("scoref");
    if (scorea.value > scoreb.value) {
    resultsa.value='Duke';
    }
    if (scoreb.value > scorea.value) {
    resultsa.value='Wake Forest';
    }
    if (scorec.value > scored.value) {
    resultsb.value='UCONN';
    }
    if (scored.value > scorec.value) {
    resultsb.value='BC';
    }
    }
    </script>
    
    Duke:<input name="scorea" type="text" id="scorea" onChange="GetScore()" size="1" maxlength="2">
    Wake Forest:<input name="scoreb" type="text" id="scoreb" onChange="GetScore()" size="1" maxlength="2">
    
    UCONN:<input name="scorec" type="text" id="scorec" onChange="GetScore()" size="1" maxlength="2">
    BC:<input name="scored" type="text" id="scored" onChange="GetScore()" size="1" maxlength="2">
    
    <select name="resultsa">
    <option value="">Winner</option>
    <option value="Duke">Duke</option>
    <option value="Wake Forest">Wake Forest</option>
    </select>
    <input name="scoree" type="text" id="scoree" onChange="GetScore()" size="1" maxlength="2">
    
    <select name="resultsb">
    <option value="">Winner</option>
    <option value="UCONN">UCONN</option>
    <option value="BC">BC</option>
    </select>
    <input name="scoref" type="text" id="scoref" onChange="GetScore()" size="1" maxlength="2">
    --------------------------------------------------
    Last edited by jscheuer1; 10-06-2007 at 06:05 AM. Reason: add code tags

  2. #2
    Join Date
    Oct 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Last edited by bers99; 10-11-2007 at 01:14 PM.

Bookmarks

Posting Permissions

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