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].inne rHTML = "<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('c loneThis') .cloneNode (true);
nr.style.display = "block";
with(nr.firstChild.firstCh ild.firstC hild.child Nodes){
item(0).childNodes[1].inne rHTML = "<SELECT SIZE=1 NAME=phone" + ind + "></SELECT>"
}
tb.appendChild(nr);
if (tbl.rows.length > 1) {
document.getElementById('d elRow').di sabled = false;
}
document.forms[0].count.va lue = ind + 1;
}
function deletRow(tbl){
if (tbl.rows.length > 1) {
tblRow = tbl.deleteRow(tbl.rows.len gth-1);
// alert(tbl.rows.length);
}
}
function disablit(tbl){
if(tbl.rows.length == 1) {
document.getElementById('d elRow').di sabled = 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("Softw are Title") & " " & rsSWProdCat1.Fields("Versi on") & CHR(34) & ">" & rsSWProdCat1.Fields("Softw are Title") & " " & rsSWProdCat1.Fields("Versi on") & "</option>"
rsSWProdCat1.MoveNext
Loop
end if
rsSWProdCat1.Close
Set rsSWProdCat1 = Nothing
%>
</SELECT></td>
</tr>
</table>
</td></tr>
</table>
<input type=button onclick="addRow(document.g etElementB yId('purch ase'))" value="Add">
<input type=button id="delRow" name="delRow" onclick="deletRow(document .getElemen tById('pur chase'));d isablit(ad dContact); " value="Delete" disabled>
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
<%
Dim cnOsmitDatabase
%>
<html>
<head>
<script language="javascript">
function addRow(tbl){
var tb = tbl.firstChild;
var ind = tb.childNodes.length;
var nr = document.getElementById('c
nr.style.display = "block";
with(nr.firstChild.firstCh
item(0).childNodes[1].inne
}
tb.appendChild(nr);
if (tbl.rows.length > 1) {
document.getElementById('d
}
document.forms[0].count.va
}
function deletRow(tbl){
if (tbl.rows.length > 1) {
tblRow = tbl.deleteRow(tbl.rows.len
// alert(tbl.rows.length);
}
}
function disablit(tbl){
if(tbl.rows.length == 1) {
document.getElementById('d
}
}
</script>
<!-- #INCLUDE FILE="dbconnection/connect
</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
' 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("Softw
rsSWProdCat1.MoveNext
Loop
end if
rsSWProdCat1.Close
Set rsSWProdCat1 = Nothing
%>
</SELECT></td>
</tr>
</table>
</td></tr>
</table>
<input type=button onclick="addRow(document.g
<input type=button id="delRow" name="delRow" onclick="deletRow(document
<br>
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points. :)
ASKER