leeny
02-23-2005, 03:50 AM
i need to update the database according to the checkboxes that are checked. my problem now is the form only gets one EMPID instead of several (suppose to be 22 of them). therefore it updates the database to changes the EmpID to the one that is being retrieved. can anyone point out what's wrong?
If Request("Submit")="Submit" then
id=request.form("id")
Dim strSelection,arrSelection
strSelection = request.form("emp")
strSelection = CStr(strSelection)
arrSelection = Split(strSelection, ", ")
For i = 0 to UBOUND(arrSelection)
sql10 = "Update ProjectAllocation Set PID = "&id&", EmpID = " & arrSelection(i) & ""
Set Rs10 = Server.CreateObject("ADODB.RecordSet")
Rs10.open sql10,conn
Next
%>
<%Else%>
<form action="editProj.asp" name="form1" method="post">
<input name="id" type="hidden" value="<%=id%>" size="35">
<table width="57%" border="0" align="center" cellpadding="4" cellspacing="4">
<tr>
<td colspan="2"><div align="center"><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>Edit
Project Details</strong></font></div></td>
</tr>
<tr bgcolor="#0000CC">
<td colspan="2"><div align="left"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Edit
</font></strong></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2"><div align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Employees
who are involved:</strong></font></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2">
<table width="550" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>
<table width="538" height="41" border="0" cellpadding="1" cellspacing="1">
<tr>
<%
rwset=1
ct=1
Do while not rs1.eof
%>
<td width="534" height="37"><div align="left">
<input name="emp" type="checkbox" id="emp" value="<%=RS1("EMPID")%>" checked>
<font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong><%=RS1("EMPID")%></strong></font></label>
<%
f=rwset mod 5
if(f=0) then
%>
</td>
</tr>
<%
end if
ct=ct+1
rwset=rwset+1
rs1.movenext
loop
%>
</table>
</td>
</tr>
</table>
If Request("Submit")="Submit" then
id=request.form("id")
Dim strSelection,arrSelection
strSelection = request.form("emp")
strSelection = CStr(strSelection)
arrSelection = Split(strSelection, ", ")
For i = 0 to UBOUND(arrSelection)
sql10 = "Update ProjectAllocation Set PID = "&id&", EmpID = " & arrSelection(i) & ""
Set Rs10 = Server.CreateObject("ADODB.RecordSet")
Rs10.open sql10,conn
Next
%>
<%Else%>
<form action="editProj.asp" name="form1" method="post">
<input name="id" type="hidden" value="<%=id%>" size="35">
<table width="57%" border="0" align="center" cellpadding="4" cellspacing="4">
<tr>
<td colspan="2"><div align="center"><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>Edit
Project Details</strong></font></div></td>
</tr>
<tr bgcolor="#0000CC">
<td colspan="2"><div align="left"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Edit
</font></strong></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2"><div align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Employees
who are involved:</strong></font></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2">
<table width="550" border="0" cellspacing="1" cellpadding="1">
<tr>
<td>
<table width="538" height="41" border="0" cellpadding="1" cellspacing="1">
<tr>
<%
rwset=1
ct=1
Do while not rs1.eof
%>
<td width="534" height="37"><div align="left">
<input name="emp" type="checkbox" id="emp" value="<%=RS1("EMPID")%>" checked>
<font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong><%=RS1("EMPID")%></strong></font></label>
<%
f=rwset mod 5
if(f=0) then
%>
</td>
</tr>
<%
end if
ct=ct+1
rwset=rwset+1
rs1.movenext
loop
%>
</table>
</td>
</tr>
</table>