I am using the following code, it adds a row to the form when the user requests it, the trouble I am having is that, the state of the row is passed to the state of the new row on the form (i.e. the data is copied from the old to new rows) I am needing to eliminate this, so the old data is kept and the new rows are blank.
I am providing the whole page of code, as the solution could be in the sql/asp at the top of the page or at the bottom. The actual code is highlighted by the line of *********
Richard Noon
I am providing the whole page of code, as the solution could be in the sql/asp at the top of the page or at the bottom. The actual code is highlighted by the line of *********
Code:
<!--#include file="security.asp" -->
<%
'File: authorised.asp
'Description: Authorised Page
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "D:/Websites/richard/admin/db/users.mdb"
for xx=1 to Request("AchDte").Count
for y=1 to Request("AchType").Count
for z=1 to Request("AchTitle").Count
for jb=1 to Request("AchGrade").Count
for jd=1 to Request("InstitutionName").Count
if xx=y Then
if xx=z Then
if xx=jb Then
if xx=jd Then
strSQL = "insert into tblQual (AchDte, AchType, AchTitle, AchGrade, InstitutionName, UserID) values ('" & Request("AchDte").Item(xx) & "', '" & Request("AchType").Item(y) & "', '" & Request("AchTitle").Item(z) & "', '" & Request("AchGrade").Item(z) & "', '" & Request("InstitutionName").Item(z) & "', '" & strUserName & "') "
'Response.Write(strSQL)
conn.Execute strSQL
End If
End If
End If
End If
next
next
next
next
next
conn.close
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr xmlns-asp="null" xmlns-shell="null"><HEAD>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="copyright" content="Copyright (C) 2005 Blue Resourcing">
<META content=en-us name=MS.LOCALE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Blue Resourcing 2005" name=keywords>
<link rel="stylesheet" type="text/css" href="css.css">
<META content="<%= Date() %>" name=last-updated>
<title><%= strUsername %>, User Panel</title>
</head>
<script language="JavaScript" src="menu.js"></script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" link="#3366CC" vlink="#008000" alink="#FF0000">
<H1><img border="0" src="images/BARLogo.gif" width="125" height="110">
Add Qualifications</H1>
<p align="center" style="margin-top: -1px; margin-bottom: -1px">
</p>
<table border="0" width="100%" id="table1">
<tr>
<td>
</td>
</tr>
<tr>
<td bgcolor="#7D7DFF" bordercolor="#7D7DFF">
<p align="center"><b><font color="#000080" size="2" face="Arial">Please
use this area to provide us with details of your Qualifications. This will help us to identify areas in which you have
experience, in order to best fit you with projects which may arise with
our Clients. Feel free to tell us of as many Qualifictions as you wish.
</font></b></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<h3>Today: <b><%= Date() %></b>, Welcome <b><%= rsCheckUser("First_Name") %> <%= rsCheckUser("Last_Name") %> (Logged
in as: <%= strUserName %>)</b>, to
<%= strWebsiteName %></h3></td>
</tr>
<table border="0" cellspacing="2" style="border-collapse: collapse" bordercolor="#111111" width="993" id="AutoNumber1" height="26">
<tr>
<td width="987" bgcolor="#5C5CA8" height="1" bordercolor="#0099CC">
<p align="left"><font color="#FFFFFF"><b>Qualifications</b></font></p>
</td>
</tr>
<tr>
<td width="987" bgcolor="#0099CC" height="1" bordercolor="#5C5CA8">
<p align="right">
</td>
</tr>
</table>
<table BORDER=1 height="44" width="994">
<form name="test" method="post" action="privatepageQual2.asp?.rand=<%= Md5Hash %>">
<tr id=baseRow>
<td height="38">Date
<p><input name="AchDte" size="8"></p>
</td>
<td height="38">Type
<p><input name="AchType" size="8"></p>
</td>
<td height="38">Subject
<p><input name="AchTitle" size="25"></p>
</td>
<td height="38">Grade
<p><textarea rows="3" name="AchGrade" cols="23"></textarea></p>
</td>
<td height="38">InstitutionName
<p><textarea rows="3" name="InstitutionName" cols="22"></textarea></p>
</td>
<td height="38">
<p align="center">Not Deletable</p>
</td>
</tr>
</table>
<p align="right">
<script language=javascript>
rowCount = 1
function addRow(){
rowCount ++
newRow = document.getElementById("baseRow").cloneNode(true)
newRow.childNodes[0].childNodes[1].name = "AchDte" + rowCount //first input in first cell
newRow.childNodes[0].childNodes[1].value = ""
newRow.childNodes[1].childNodes[1].name = "AchType" + rowCount //first input in second cell
newRow.childNodes[1].childNodes[1].value = ""
newRow.childNodes[2].childNodes[1].name = "AchTitle" + rowCount //first input in third cell
newRow.childNodes[2].childNodes[1].value = ""
newRow.childNodes[3].childNodes[1].name = "AchGrade" + rowCount //first input in fourth cell
newRow.childNodes[3].childNodes[1].value = ""
newRow.childNodes[4].childNodes[1].name = "InstitutionName" + rowCount //first input in fifth cell
newRow.childNodes[4].childNodes[1].value = ""
newRow.id = "row" + rowCount
newButton = document.createElement("input")
newButton.id = "button" + rowCount
newButton.type = "button"
newButton.value = "Delete"
newButton.attachEvent("onclick", deleteRow)
newRow.childNodes[5].childNodes[0].replaceNode(newButton)
document.getElementById("baseRow").parentNode.appendChild(newRow)
}
function deleteRow(){
buttonID = event.srcElement.id // ie - "button2"
rowID = buttonID.substr(6) // ie - "2"
document.getElementById("row" + rowID).removeNode(true)
}
</script>
<input type=button value="Add Another Qualification" onClick="addRow()" name="AddQual" style="float: left">
<input type="submit" value="Submit >>"><input type="button" value="Cancel & Return to Main Menu" onClick="history.go(-1)"><b><font size="4" face="Arial Black">
</font></b></p>
<p> </p>
<input type="hidden" name="cryptKey" value="<%= strSecurityKey %>">
</body>
<!-- #include file="footer.asp" -->
<%
'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing
%>
Richard Noon