SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: drop down boxes

  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    drop down boxes

    Heres what I am hoping someone can explain to me or show me an example...

    I am writing a page in php, but want to add javascript to handle the page so I dont need to keep reloading.

    I want to have a bracket page, so you can chose from two options, and then two chosen people are paried to face off... espn.com has a bracket for the sexiest athlete right now - something like that. What I want is drop down box 1A to have two options. When one option is chosen, it is added to box 2A. The user would also chose one of two options from 1B. That choice would also be added to 2A. Then I need this to recursively work for N number of rounds, and the total to start would be 2^N.

    Does anyone understand what I need and is willing to help?

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Is something like this what you're looking for?

    <script language="JavaScript">
    <!--
    function onChange(selVal, selName) {
    num = (parseInt(selName.substr(4)))
    num += (num %2 == 0) ? 1 : 2;
    nextSel = 'game' + num
    selObj = eval('document.picks.' + nextSel)

    selObj.options[selObj.options.length] = new Option(selVal, selVal);
    if (document.layers) history.go(0)

    }
    //-->
    </script>

    </HEAD>
    <BODY>

    <form name="picks" action="showpicks.asp" method="post">
    <br>
    <SELECT name="game1" onChange="onChange(this.options[this.selectedIndex].value, this.name)">
    <OPTION value="Duke">Duke</OPTION>
    <OPTION value="St. Bonaventure">St. Bonaventure</OPTION>
    </SELECT>
    <br><br>
    <SELECT name="game2" onChange="onChange(this.options[this.selectedIndex].value, this.name)">
    <OPTION value="Florida">Florida</OPTION>
    <OPTION value="Temple">Temple</OPTION>
    </SELECT>
    <br><br>
    <SELECT name="game3">
    </SELECT>
    </form>
    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vinny, you are the man. i am helping JKH with this project of ours and your code snippet has led me on the perfect track. Thank you so much.

    Drew
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    March Madness, Super Bowl, or the US Open?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    March Madness
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.

  6. #6
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have an enhancement I hope you can help with. The code I want to use has a team name, and a team id associated. I want the second round to be populated from data from the first round. That works cool, except I want the "value" and the "label" passed..

    If round 1 has

    <OPTION value="543">Duke</OPTION>

    I want the second round to be populated with the "543" and the "Duke" if Duke is chosen in the first round. Right now the value 543 is passed to the second round.

    What modifications can I make?


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
  •