Need help modifying i++ count code.

Discussion in 'JavaScript' started by jramaro, Jun 27, 2007.

  1. #1
    I have this script that would show the <div> tags based on user selection from one select menu.

    I want to change it so that it works i na new way.

    I have 7 select menus. Stacked like this,
    1.
    2.
    3.
    4.
    5.
    6.
    7.


    I want this script to only add the next <div>
    so it would only be adding +1

    here's the old script

    <script language="JavaScript">
    function ShowMenu(num, menu, max)
    {
    //starting at one, loop through until the number chosen by the user
    for(i = 1; i <= num; i++){
    //add number onto end of menu
    var menu2 = menu + i;
    //change visibility to block, or 'visible'
    document.getElementById(menu2).style.display = 'block';
    }
    }
    </script>


    see the line : for(i = 1; i <= num; i++){

    Instead i want it so that when user makes a selection on Select menu 1, it will then show Select menu 2. when user makes a selection on Select menu 2, it will then show Select menu 3. etc .

    How do i change that to add 1 , or as many as i want?

    thank you
     
    jramaro, Jun 27, 2007 IP