Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help need with updating sql from mulitple selects

Status
Not open for further replies.

kennyku

MIS
Feb 5, 2008
1
US
I am trying to update a list of reports with certain attributes. I select the report with a checkbox, then choose certain attributes with select dropdowns and a textarea. I can chose the correct report to update, but the other fileds are not working. Thanks.

page one:
<%
On Error Resume Next
rs2.MoveFirst
do while Not rs2.eof
%>
<TR>
<TD width=250 ><TEXTAREA name="zReportName" cols=55 rows=1 style="font-family: arial; font-size: 12px;" readonly>
<%=Server.HTMLEncode(rs2.Fields("ReportName").Value)%></TEXTAREA>
</TD>
<TD width=120 align=center><FONT SIZE=-2 FACE="Verdana" COLOR=#000000><big>I use this report:</big>
<input type="checkbox" name="zReportUse"
value="<%=Server.HTMLEncode(rs2.Fields("ReportID").Value)%>" style="width:120px;">
</TD>
<TD width=110 ><select name="zReportType" style="font-family:Verdana;font-size:10px;width:120px;" >
<option value="gram">green</option>
<option value="Excel Extract">Excel Extract</option>
<option value="Formatted Hard Copy">Formatted Hard Copy</option>
<option value="Extract and Report">Extract and Report</option>
</select></TD>
<TD width=110 ><select name="zReportNeed" style="font-family:Verdana;font-size:10px;width:120px;">
<option value="clam ">pink</option>
<option value="Mission Critical">Mission Critical</option>
<option value="Very Important">Very Important</option>
<option value="Somewhat Important">Somewhat Important</option>
<option value="May Not be Needed">May Not be Needed</option>
</select> </TD>
<TD width=250 ><TEXTAREA name="zReportNotes" cols=55 rows=2 wrap=physical style="font-family: arial; font-size: 12px;"></TEXTAREA><br />

</TR>
<%
rs2.MoveNext
loop%>

page two:

<%
Dim i,arrUse,arrType,arrNeed,arrNotes
arrUse=Split(request.Form("zReportUse"),",")
arrType=Split(request.Form("zReportType"),",")
arrNeed=Split(request.Form("zReportNeed"),",")
arrNotes=Split(request.Form("zReportNotes"),",")
for i=lbound(arrUse) to Ubound(arrUse)
sSQL="update tbl_UserReports set ReportType='"& arrType(i) &"',ReportNeed='"& arrNeed(i) &"',ReportNotes='"& arrNotes(i) &"',Complete = 'x' where ReportID = "& arrUse(i) &" "
conntemp.Execute sSQL
next
%>

 
The reason it does not work in general (but it can work in particular circumstances) is that the checkbox control if not checked will not be returned. Hence, if you set up the rs.movenext etc loop with a single name for the whole set of checkbox and select-one elements, after the submit, chances are the split() results in uneven size... hence problem of mis-alignment and/or out of range.

You have to give each group (for each pass of rs.movenext) a indexed name such as (zReportName_1, zReportUser_1, zReportType_1, zReportNeed_1, zReportNotes_1) with varying 1,2,3,... and then deal with unchecked checkbox cases with server-side script in the page two.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top