49 users online (1 members and 48 guests)  


  Results 1 to 1 of 1

Related

  1. Stop refreshing iframe    Forum: Javascript Forum
    Replies: 2
  2. Help me stop my hedging....    Forum: General Discussion
    Replies: 5
  3. Stop Inline Frame    Forum: Website Scripts Forum
    Replies: 1
  4. stop bg music link?    Forum: HTML Forum
    Replies: 1
  1. #1
    accel's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    1

    to stop row growing in table

    pls help me
    i wish to know how to stop growing rows in a table using the javascript.
    pressing enter key in a row will create a new row but it must stop creating row while pressing again
    the code is given below

    Code:
    <html >
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    <center>
    <TABLE border="1" ID="tblrol" STYLE="border width:1 orange dashed;background color:<h3></h3>;table-row width:2;">
    <TR><TH bordercolor="#3298BE">Quantity Ordered</TH>
    <TH bordercolor="#3298BE">UoM</TH>
    <TH bordercolor="#3298BE">Item Number</TH>
    <TH bordercolor="#3298BE">Ln By</TH>
    </TR>
    <TR><TD ALIGN="center"><INPUT TYPE="text" onKeyDown="if(event.keyCode==13) addRow('tblrol')" NAME="in_name" SIZE="30" MAXLENGTH="30"></TD><TD ALIGN="center"><INPUT TYPE="text" onKeyDown="if(event.keyCode==13) addRow('tblrol')" NAME="in_name" SIZE="30" MAXLENGTH="30" STYLE="height:24;border: 1 solid;margin:0;" ></TD>
      <TD ALIGN="center"><INPUT TYPE="text" onKeyDown="if(event.keyCode==13) addRow('tblrol')" NAME="in_name" SIZE="30" MAXLENGTH="30" STYLE="height:24;border: 1 solid;margin:0;" ></TD>
      <TD ALIGN="center"><INPUT TYPE="text" onKeyDown="if(event.keyCode==13) addRow('tblrol')" NAME="in_name" SIZE="30" MAXLENGTH="30" STYLE="height:24;border: 1 solid;margin:0;" ></TD>
    </TR>
    </TABLE>
    <SCRIPT TYPE="text/javascript">
    var count = "1";
    function addRow(in_tbl_name)
    {
    <!--var oRow = oTable.insertRow(-1); -->
    var tbody = document.getElementById(in_tbl_name).getElementsByTagName("TBODY")[0];
    // create row
    <!--var oRow = oTable.insertRow(-1); -->
    var row = document.createElement("TR");
    // create table cell 1
    var td1 = document.createElement("TD");
    var strHtml1 = "<INPUT TYPE=\"text\" onKeyDown=\"if(event.keyCode==13) addRow('tblrol')\" NAME=\"in_name\" SIZE=\"30\" MAXLENGTH=\"30\" STYLE=\"height:24;border: 1 solid;margin:0;\" >";
    td1.innerHTML = strHtml1.replace(/!count!/g,count);
    var td2 = document.createElement("TD");
    var strHtml2 = "<INPUT TYPE=\"text\" onKeyDown=\"if(event.keyCode==13) addRow('tblrol')\" NAME=\"in_name\" SIZE=\"30\" MAXLENGTH=\"30\" STYLE=\"height:24;border: 1 solid;margin:0;\" >";
    td2.innerHTML = strHtml2.replace(/!count!/g,count);
    var td3 = document.createElement("TD");
    var strHtml3 = "<INPUT TYPE=\"text\" onKeyDown=\"if(event.keyCode==13) addRow('tblrol')\" NAME=\"in_name\" SIZE=\"30\" MAXLENGTH=\"30\" STYLE=\"height:24;border: 1 solid;margin:0;\" >";
    td3.innerHTML = strHtml3.replace(/!count!/g,count);
    var td4 = document.createElement("TD");
    var strHtml4 = "<INPUT TYPE=\"text\" onKeyDown=\"if(event.keyCode==13) addRow('tblrol')\" NAME=\"in_name\" SIZE=\"30\" MAXLENGTH=\"30\" STYLE=\"height:24;border: 1 solid;margin:0;\" >";
    td4.innerHTML = strHtml4.replace(/!count!/g,count);
    
    // append data to row
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    // //row.appendChild(td3);
    // add to count variable
    count = parseInt(count) + 1;
    // append row to table
    tbody.appendChild(row);
    }
    </SCRIPT>
    </body>
    </html>
    waiting for the results
    Last edited by vinyl-junkie; 11-30-2007 at 07:02 AM. Reason: Added code tags



Tags for this Thread