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!

Querystring and Send Multiple

Status
Not open for further replies.

danieljoo

MIS
Oct 9, 2002
43
0
0
US
I have a asp page that displays company information from a database. The page lists company name, company number, company address and a checkbox. If the checkbox is selected and the user selects the print button at the bottom of the page, the querystring should send company number and checkbox (yes) to another page to be printed. Multiple companies can be selected to be printed on the same page. The checkbox is called "PrintCompany". How do I setup the querystring on the first page to send the data and how do I setup the second page to display it to print?
 
If i understabd correctly you have say 10 comanpies listed on a page and I can print 1, 2, 3 or all of them. Each comapmny name has a checkbox beside it called "PrintCompany" if this is checked then its a company I want printed. If you make the checked value of each "PrintCompany" the record id of the commnay in the table I.E so if i want to print company 1, 5 and 7, in the list and their records ids are 123456, 654798, and 32165 the your Request.Form("PrintCompany") = "123456, 654798, 32165" which you can use aryCompaniesToPrint = Split(Request.Form("PrintCompany"), ", ") 'this will convert each value in the array to a record id. Then query your DB with
For i = 1 to ubound(aryCompaniesToPrint)
strSQL = "SELECT * FROM tblComapnies WHERE RecordID='" & aryCompaniesToPrint(i) & "'"
dbconn.execute(strSQL)
<-- format record for the screen-->
Next

This will loop through the array (in this case) 3 times and return the records on the page you want to printed.

Hope this helps, I will watch the post if you need more help.
 
Since the browser should already put them in a comma separated list, the only loop needed is when you print them out.

<%
If Request.Form(&quot;PrintCompany&quot;)=&quot;&quot; Then
Response.Write &quot;No companies selected&quot;
Else
sql=&quot;SELECT * FROM tblCompanies WHERE CompanyID IN (&quot; & Request.Form(&quot;PrintCompany&quot;) & &quot;)&quot;
Set objRS=objConn.Execute(sql)
Do While Not objRS.EOF
Response.Write objRS.Fields(&quot;Name&quot;) & &quot; - &quot;
Response.Write objRS.Fields(&quot;Number&quot;) & &quot;<br>&quot;
objRS.MoveNext
Next
End If
%>
Adam
 
The replies I've received seem to make sense when I try to read in the querystring on the print page, but I can't get the querystring to work properly. Below is the code used to read in the company info from the database, along with the option for the user to select which companies information they would like to print. The querystring currently shows &quot;print.asp?CustomerNumber= &quot; (no value). Seems there should be some kind of loop?



<%
'Avoid starting record > total records
if clng(startRec) > clng(totalRecs) then
startRec = totalRecs
end if
'Set the last record to display
stopRec = startRec + displayRecs - 1

'Move to first record directly for performance reason
recCount = startRec - 1
if not rs.eof then
rs.movefirst
rs.move startRec - 1
end if

recActual = 0
Do While (NOT rs.EOF) AND (recCount < stopRec)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1 %>

<%
'set row color
bgcolor=&quot;#FFFFFF&quot;
%>

<%
' Display alternate color for rows
If recCount mod 2 <> 0 Then
bgcolor=&quot;#F5F5F5&quot;
End If
%>

<%
x_CustomerNumber = rs(&quot;CustomerNumber&quot;)
x_CustomerName = rs(&quot;CustomerName&quot;)
x_CustomerAddress = rs(&quot;CustomerAddress&quot;)
x_CustomerCity = rs(&quot;CustomerCity&quot;)
x_CustomerState = rs(&quot;CustomerState&quot;)
x_CustomerZip = rs(&quot;CustomerZip&quot;)
x_CustomerGrpCode = rs(&quot;CustomerGrpCode&quot;)
x_ID = rs(&quot;ID&quot;)
x_Print = rs(&quot;Print&quot;)
%>


<tr bgcolor=&quot;<%= bgcolor %>&quot;>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerNumber %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerName %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerAddress %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerCity %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerState %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerZip %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_CustomerGrpCode %>&nbsp;
</font></td>
<td><font size=&quot;-1&quot;>
<% response.write x_ID %>&nbsp;
</font></td>
<td>
<font size=&quot;-1&quot;>

<input type=&quot;checkbox&quot; name=&quot;Print&quot;<%if (x_Print)=true then%>
checked value=&quot;ON&quot;>
<%else%>
>
<%end if%>
</font></td>
</tr>

<%
end if

rs.MoveNext
Loop
%>

<tr bgcolor=&quot;#ffffff&quot;>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>

<td><a target=&quot;_blank&quot; href=&quot;print.asp?CustomerNumber=<%if Request.Querystring(&quot;Print&quot;)=true then%><%=x_CustomerNumber%><%end if%>&quot;><img src=&quot;images/printer.gif&quot; border=&quot;0&quot;></a></td>

</tr>
</table>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top