Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    hmc
    hmc is offline
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    guys, help with code please.

    i have a nice script which show me plan details.
    but it was developed only for 2 plans.
    in my service i have about 5 plans.
    how its possible to add more plans to this javascript?

    please help with it.

    Code:
    <script language="javascript" type="text/javascript">
    <!--
       
        function flipTerabyte(isTerabyte) {
            if ((isTerabyte) && document.getElementById("terabytePlans").style.display == "") return;
            if ((!isTerabyte) && document.getElementById("gigabytePlans").style.display == "") return;
            
            if (isTerabyte) {
                document.getElementById("gigabytePlans").style.display = "none";
                document.getElementById("terabytePlans").style.display = "";
               
                
            }
            else {            
                document.getElementById("terabytePlans").style.display = "none";
                document.getElementById("gigabytePlans").style.display = "";
                          
                
            }
            
        }
    //-->
    </script>	 
    <a href="#" onClick="flipTerabyte(false);return false" style="text-decoration:none;">plan1</a>
    <a href="#" onClick="flipTerabyte(true);return false" style="text-decoration:none;">plan2</a>					
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="gigabytePlans">
      <tr>
        <td>plan1 details</td>
      </tr>
    </table>          
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="terabytePlans" style="display:none">
      <tr>
        <td>plan2 details</TD></TR>
                    			</TABLE>

  • #2
    Regular Coder Nischumacher's Avatar
    Join Date
    Oct 2005
    Location
    Bombay, India
    Posts
    196
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    var tableArray = new Array('table1', 'table2', 'table3', 'table4', 'table5');
    
    function showTable(which) {
    hideAll();
    var tempTable = document.getElementById(tableArray[which]);
    tempTable.style.display = 'block';  //or ''
    }
    }
    
    function hideAll() {
    for(var ArrayIndex=0; ArrayIndex<5; ArrayIndex++) {
    document.getElementById(tableArray[ArrayIndex]).style.display = 'none';
    }
    }
    
    ...
    
    <table id="table1"><tr><td>plan1 details</td></tr></table>
    <table id="table2"><tr><td>plan2 details</td></tr></table>
    <table id="table3"><tr><td>plan3 details</td></tr></table>
    <table id="table4"><tr><td>plan4 details</td></tr></table>
    <table id="table5"><tr><td>plan5 details</td></tr></table>
    
    ...
    
    <a href="#" onClick="showTable('0');return false">plan1</a>
    <a href="#" onClick="showTable('1');return false">plan2</a>
    <a href="#" onClick="showTable('2');return false">plan3</a>
    <a href="#" onClick="showTable('3');return false">plan4</a>
    <a href="#" onClick="showTable('4');return false">plan5</a>
    - NS 666
    .net DEVILoper


  •  

    Posting Permissions

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