I created a dynamic table in ASP/VBScript that populates a table from a recordset. Using a DO LOOP a new row is created for each new EmployeeID. The drop-down lists have 2 options: "check-in" and "check-out." If "check-in" is selected the comment box will remain disabled and if the "check-out" item is selected the comment box will be enabled; both options will generate a date when selected.

The problem is that the drop-down list only works on the first row.

I know I need to rewrite the code so it will call the **test()** function each time there is a new row. 

So is there some way I can clone the function and have it execute for each row? I've already tried making the function name and IDs dynamic by adding a rowCount to their ID name (example: "id="TestCmt<%=rowTest%>) 

Maybe someone can point me in the right direction? I've spent hours on this and I'd like to figure it out (somewhat) on my own :)

Here's some of the code:

```
 <html xmlns:ntb>
 <head>
  <script language="javascript" type="text/javascript">

  function enable() {
  document.getElementById("TestCmt").readOnly = false;
  document.getElementById("TestCmt").style.backgroundColor = "#FFFFFF";
  document.getElementById("TestCmt").innerHTML = "";
  document.getElementById("TestCmt").style.color = "#000000";
  }

  function disable() {
  document.getElementById("TestCmt").readOnly = true;
  document.getElementById("TestCmt").style.backgroundColor = "#DCDCDC";
  document.getElementById("TestCmt").innerHTML = "";
  }

  function test() {
  <%  if (StoreID > 0) AND (rsTest.bof=FALSE) then %> //Make sure there are employees

  var selectMenuT = document.getElementById("TestStatus");
  selectMenuT.onchange = function () {

    var chosenOptionT = parseInt(this.options[this.selectedIndex].value);
    var textDateT = document.getElementById("TestDate");
    var cmtsT = document.getElementById("TestCmt");

    switch (chosenOptionL) {

    case 0:
    disable();
    textDateT.innerHTML = "";
    cmtsT.innerHTML = <%=rsTest("TestCmt")%>
    break;

    case 1:
    disable();
    var approve = getReviewDate(); //excluded this function from here but it works fine
    textDateT.innerHTML = approve;
    break;

    case 2:
    enable();
    var reject = getReviewDate();
    textDateL.innerHTML = reject;
    break;
    }
   }
   <% end if %>
  } 
  </script>
 </head>

<body>

<%  if (StoreID > 0) and rsTest.BOF=FALSE then %> 

 <span class="header">Test Playground - Store# <%=rsStore("StoreNo")%></span>

 <table class="table" name="StoreTable" cellpadding="1" cellspacing="0">
  <tr>
   <td class="TestHeader">Store No.</td>
   <td class="TestHeader">Check-In Status</td>
   <td class="TestHeader">Date</td>
   <td class="TestHeader">Comments</td>
 </tr>

<%         
  dim i3, iStr3
  dim rowTest
  rowTest = 0

  do until rsTest.EOF 
  i3=clng(rsTest("EmployeeID"))
  iStr3=right("000"+cstr(i3),4)
  rowTest = rowTest + 1
%>

 <tr>
   <!-- Store No.-->
   <td>
    <% if StoreID > 0 then %>
    <label id="TestRN<%=rowTest%>"></label>
   </td>

  <!-- Check-In Status-->
  <td class="TestData" valign="top">
    <select id="TestStatus<%=rowTest%>" style="width:100%" **onchange="test()"**>
      <option value="0">&lt;Select one&gt;</option>
      <option value="1">Check-In</option>
      <option value="2">Check-Out</option>
    </select>
  </td>

  <!--Date-->
  <td valign="top">
    <input type="hidden" name="Sequence<%=iStr3%>" id="Sequence<%=iStr3%>">
    <label ID="TestDate<%=rowTest%>" class="TestData"><%=rowTest%></label>
  </td>

  <!--Comments-->
  <td valign="middle">
    <textarea id="TestCmt<%=rowTest%>" rows="2" style="textarea" ReadOnly ></textarea>
  </td>
  <% end if %>
</tr>

 <%
 rsTest.MoveNext
 loop 
 %>

 </table>
 <% end if %>

 </body>
</html>

```

---

Any help is appreciated.

Signed: The Learning Noob