Link to home
Start Free TrialLog in
Avatar of gifford_c
gifford_c

asked on

Dropdown menu help in add row script

I using the code below and the dropdown menu works fine for the database populated dropdown list.  What I want if when I click Add it creates the database populated list again.  If I move the asp script into the line item(0).childNodes[1].innerHTML = "<SELECT SIZE=1 NAME=phone" + ind + "></SELECT>" and remove all the " for ' nothing happens.  Can someone help?

<%
Dim cnOsmitDatabase
%>
<html>
<head>
<script language="javascript">
function addRow(tbl){
 var tb = tbl.firstChild;
 var ind = tb.childNodes.length;
 var nr = document.getElementById('cloneThis').cloneNode(true);
 nr.style.display = "block";
 with(nr.firstChild.firstChild.firstChild.childNodes){
   item(0).childNodes[1].innerHTML = "<SELECT SIZE=1 NAME=phone" + ind + "></SELECT>"
 }
 tb.appendChild(nr);
 if (tbl.rows.length > 1) {
   document.getElementById('delRow').disabled = false;
 }
 document.forms[0].count.value = ind + 1;
}

function deletRow(tbl){
  if (tbl.rows.length > 1) {
    tblRow = tbl.deleteRow(tbl.rows.length-1);
    //           alert(tbl.rows.length);
  }
}
function disablit(tbl){
  if(tbl.rows.length == 1) {
    document.getElementById('delRow').disabled = true;
  }
}
</script>
<!-- #INCLUDE FILE="dbconnection/connect.asp" -->
</head>
<body>
<%
  count = request.form("count")
  for i = 0 to cint(count) - 1
    phone = request.form("phone" & i)
    response.write "phone = " & phone & "<br>"
  next
%>
<form name="addAccount" method="post" >
<%
      DBConnect

      Dim rsHWProdCat
      Dim rsSWProdCat
             
      Dim strSQL
                   
      Set rsSWProdCat1 = Server.CreateObject("ADODB.RecordSet")

      ' SQL to get the software titles.
      strSQL = "SELECT * FROM software WHERE (([StdBuildComponent] = FALSE) AND ([Status] = 'Approved')) ORDER BY [Software Title] ASC;"
      rsSWProdCat1.Open strSQL, cnOsmitDatabase
 %>
<input type=hidden name="count" value="1">
<table id="purchase">
<tr id='cloneThis'>
<td>
<table border=0>
<tr>
<td>Phone</td>
<td colspan=5><SELECT SIZE="1" NAME="phone0">
<%
          if Not rsSWProdCat1.EOF Then
      rsSWProdCat1.MoveFirst
      Do While Not rsSWProdCat1.EOF
      Response.Write "<option value=" & chr(34) & rsSWProdCat1.Fields("Software Title") & " " & rsSWProdCat1.Fields("Version") & CHR(34) & ">" & rsSWProdCat1.Fields("Software Title") & " " & rsSWProdCat1.Fields("Version") & "</option>"
      rsSWProdCat1.MoveNext
      Loop
      end if
      rsSWProdCat1.Close
      Set rsSWProdCat1 = Nothing
%>
</SELECT></td>
</tr>
</table>
</td></tr>
</table>
<input type=button onclick="addRow(document.getElementById('purchase'))" value="Add">
<input type=button id="delRow" name="delRow" onclick="deletRow(document.getElementById('purchase'));disablit(addContact);" value="Delete" disabled>
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of lil_puffball
lil_puffball
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gifford_c
gifford_c

ASKER

Worked a treat.  Points to you.
Thanks for the points. :)