Display table repeatedly on Combo box selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aswincts
    New Member
    • Feb 2007
    • 3

    Display table repeatedly on Combo box selection

    I want to display repeat a <table> based on the count given in combo box

    Please help me
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Changed thread title.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by aswincts
      I want to display repeat a <table> based on the count given in combo box

      Please help me
      To display a table, you can do that in two ways, either use the standard DOM methods or just use innerHTML. For the DOM method, see here.

      For combo boxes, do you want it on selection, or activated by a button click?

      Comment

      • dorinbogdan
        Recognized Expert Contributor
        • Feb 2007
        • 839

        #4
        Just a small sample :

        [HTML]
        <html>
        <head>
        <title>Copy table</title>
        </head>
        <script language="JavaS cript">
        function CopyTable(){
        var tbl = document.getEle mentById("tbl") ;
        var sel = document.getEle mentById("sel") ;
        var max = sel.options[sel.selectedInd ex].value;
        for (var i=1;i<=max;i++) {
        var tbl2 = tbl.cloneNode(t rue);
        tbl2.id = "tbl"+i;
        document.body.a ppendChild(tbl2 );
        }

        }
        </script>
        <body>
        <select id="sel">
        <option value="1">one copy</option>
        <option value="2">two copies</option>
        <option value="3">three copies</option>

        </select>
        <input type="button" onclick="CopyTa ble()" value="Copy table">
        <table border="1" id="tbl"><tr><t d>Table1</td></tr></table>
        </body>
        </html>
        [/HTML]

        Comment

        Working...