Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dropdown menu help in add row script

Posted on 2004-03-26
3
Medium Priority
?
230 Views
Last Modified: 2008-03-10
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>
0
Comment
Question by:gifford_c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
lil_puffball earned 1000 total points
ID: 10691777
Why do you need to recreate it? If you want to change the name of the select, use this function:

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.firstChild.childNodes[1].firstChild){
   id="phone"+ind;
   name="phone"+ind;
 }
 tb.appendChild(nr);
 if (tbl.rows.length > 1) {
   document.getElementById('delRow').disabled = false;
 }
 document.forms[0].count.value = ind + 1;
}
0
 

Author Comment

by:gifford_c
ID: 10691841
Worked a treat.  Points to you.
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10692059
Thanks for the points. :)
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question