Recordset Single print

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spenc
    New Member
    • Dec 2013
    • 3

    Recordset Single print

    Hi, Please I want a PrintAll button that can print all tickets onclick. The other codes work perfectly except the last line. It tells me undefined. Actually it is registration tickets I want to print. Pls see attached image.

    Thanks
    Code:
        RS1.Open SQL, cnn, 0, 1
    	
    	if request.Form("id") = "" then
    %>
    	<table class="cobtbl" width="100%" border="0" cellspacing="1" cellpadding="3">
    	<tr>
    		
    		<td class="cobhl" align="center"><strong>Full Name</strong></td>
                    <td class="cobhl" align="center"><strong>Attendee Type</strong></td>
    		<td class="cobhl" align="center"><strong>Company</strong></td>
    		<td class="cobhl" align="center"><strong>Item</strong></td>
    		<td class="cobhl" align="center"><strong>Print</strong></td>
    <%
    	do while not rs1.eof %>
    		<tr>
    		    <td align="center"><%=rs1("FullName")%></td>
    			<td align="center"><%=rs1("AttendeeType")%></td>
    			<td align="center"><%=rs1("CompanyName")%></td>
    			<td align="center"><%=rs1("Item1")%></td>
    		       	<td align="center"><input type="button"  title="Print"  value="Print" onclick="printrec('<%=rs1("ConfirmationNo")%>','<%=rs1("FullName")%>','<%=rs1("CompanyName")%>','<%=rs1("Item1")%>')" /></td>
                           
                         </tr>
                       
    <%
    		rs1.movenext
    	loop
    	
    	rs1.close: set rs1=nothing
    %>
    
    <td align="center"><input type="button"  title="Print"  value="Print All Tickets" onclick="printrec()"
    Attached Files
    Last edited by Frinavale; Dec 4 '13, 06:20 PM. Reason: Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    When developing a website there are 2 sets of code that you need to consider:
    1. Client-Side code: code that is run in the web browser
    2. Server-Side code: code that is run on the web server


    You have HTML markup for a button in the code that you posted. Once rendered by the browser, this button exists in the browser and has client-side events that are associated with it. One of these client-side events is the "onclick" event. You provide it with a JavaScript method to call when this event is fired (remember, JavaScript runs in the browser and so it is "client-side" code)

    So, the following will indicate that when the button is clicked it should call a JavaScript function named "printrec() ":
    Code:
    <input type="button"  
      title="Print"  
      value="Print All Tickets" 
      onclick="printrec()"/>
    If you do not have a JavaScript function named "printrec() " then you will get a client-side error along the lines of "Object not defined".

    So, to fix the problem you should define a function called "printrec() " which calls the JavaScript window.print() method to open a print dialogue and allow the user to specify where to print to.

    Like this:
    Code:
    <script type="text/javascript">
    function printrec(){
      window.print();
    }
    </script> 
    <input type="button"  
      title="Print"  
      value="Print All Tickets" 
      onclick="printrec()"/>
    If you wanted this to be printed out at the server, than you would not handle the client-side click event as you are. Instead, you would have to submit to server-code that would do the printing for you.



    -Frinny


    (PS: Please note that the HTML for your button that you posted is not valid because you are missing the close tag for it...but you are also missing the close tag for the td element as well so I'll assume it's just a copy/paste mistake).
    Last edited by Frinavale; Dec 10 '13, 03:11 PM.

    Comment

    • spenc
      New Member
      • Dec 2013
      • 3

      #3
      Hi Frinny,
      Thanks for your response. the tag was a copy and paste error.
      I have the function printrec() .
      let me paste the entire code:
      Code:
      <html>
      <head>
      <script language="javascript" type="text/javascript">
      function printrec(id,fn,comp,it){
      	document.forms.psearchform.id.value = id;
      	document.forms.psearchform.fn.value = fn;
      	document.forms.psearchform.comp.value = comp;
      	document.forms.psearchform.it.value = it;
      	document.forms.psearchform.act.value = "printrec";
      	document.forms.psearchform.submit();
              
      }
      </script>
      </head> 
       
      <form method="post" action="printbadge.asp" name="psearchform">
      			<input type="hidden" name="act" value="" />
      			<input type="hidden" name="id" value="" />
      			<input type="hidden" name="fn" value="" />
      			<input type="hidden" name="comp" value="" />
      			<input type="hidden" name="it" value="" />
      </form>
      
      <%
      
      Response.Buffer = True
      isadmincsv=TRUE
      
      Function iif(expression, truePart, falsePart)
      	If expression Then
      		iif = truePart
      	Else
      		iif = falsePart
      	End If
      End Function
      Dim sDSN
      sDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files (x86)\EventPro Software\Attendee Online\App_Data\webdata.mdb;" 
      set RS1 = Server.CreateObject("ADODB.RECORDSET")
      Set cnn=Server.CreateObject("ADODB.Connection")
      cnn.open sDSN
      	
      	SQL = "SELECT EventAttendee.UniqueID, EventAttendee.BookNo, EventAttendee.AttendeeType, EventAttendee.FullName, EventAttendee.NameBadge, EventAttendee.CompanyName, EventAttendee.ConfirmationNo, EventRegGroup.RegGroup, EventReg.Item, iif(EventReg.Item is null,EventRegGroup.RegGroup, EventReg.Item) as Item1 FROM (EventRegGroup INNER JOIN (((EventAttendee INNER JOIN EventAttendeeReg ON (EventAttendee.UniqueID = EventAttendeeReg.EventAttendeeID) AND (EventAttendee.BookNo = EventAttendeeReg.BookNo)) INNER JOIN EventAttendeeRegGroup ON (EventAttendee.BookNo = EventAttendeeRegGroup.BookNo) AND (EventAttendeeReg.UniqueID = EventAttendeeRegGroup.EventAttendeeRegID) AND (EventAttendee.UniqueID = EventAttendeeRegGroup.EventAttendeeID)) LEFT JOIN EventAttendeeRegGroupDetail ON EventAttendeeRegGroup.UniqueID = EventAttendeeRegGroupDetail.EventAttendeeRegGroupID) ON EventRegGroup.UniqueID = EventAttendeeRegGroup.EventRegGroupID) LEFT JOIN EventReg ON EventAttendeeRegGroupDetail.EventRegID = EventReg.UniqueID WHERE (EventAttendee.StatusID = {guid {6B7B1795-8717-4E7B-B504-A4EA6BCD4D08}}) AND EventAttendee.ConfirmationNo ='" & request.QueryString("id") & "'"
      
      
      
      	
      	
          RS1.Open SQL, cnn, 0, 1
                     
      	if request.Form("id") = "" then
      %>
      	<table class="cobtbl" width="100%" border="0" cellspacing="1" cellpadding="3">
      	<tr>
      		<td class="cobhl" align="center"><strong>Confirmation No</strong></td>
      		<td class="cobhl" align="center"><strong>Full Name</strong></td>
      		<td class="cobhl" align="center"><strong>Company</strong></td>
      		<td class="cobhl" align="center"><strong>Item</strong></td>
      		<td class="cobhl" align="center"><strong>Print</strong></td>
      <%
      	do while not rs1.eof %>
      		<tr>
      		    <td align="center"><%=rs1("ConfirmationNo")%></td>
      			<td align="center"><%=rs1("FullName")%></td>
      			<td align="center"><%=rs1("CompanyName")%></td>
      			<td align="center"><%=rs1("Item1")%></td>
      			<td align="center"><input type="button"  title="Print"  value="Print" onclick="printrec('<%=rs1("ConfirmationNo")%>','<%=rs1("FullName")%>','<%=rs1("CompanyName")%>','<%=rs1("Item1")%>')" /></td>
      	</tr>
      <%
      		rs1.movenext
      	loop
      	
      	set rs1=nothing
      %>
      </table>
      <input type="button"  title="Print"  value="Print All" onclick="printrec()" /> 
      <%else
      
      cnn.Execute("UPDATE EventAttendee SET EventAttendee.AccomQuantity = 1 WHERE (EventAttendee.StatusID = {guid {6B7B1795-8717-4E7B-B504-A4EA6BCD4D08}}) AND (EventAttendee.AccomQuantity = 0) AND EventAttendee.ConfirmationNo ='" & request.Form("id") & "'")
      
      Dim imgPath
      if request.Form("it") <> "" then
      if Instr(request.Form("it"), "Pass") > 0 then
      	imgPath="ONEDAYPASS"
      elseif Instr(request.Form("it"), "Course")  > 0 then
      	imgPath="BROWN"
      elseif Instr(request.Form("it"), "Young") > 0 then
      	imgPath="AYPC1"
      elseif Instr(request.Form("it"), "Adhoc") > 0 then
      	imgPath="GREEN"
      elseif Instr(request.Form("it"), "Booth") > 0 then
      	imgPath="BOOTH_FAMILY"
      elseif Instr(request.Form("it"), "Complimentary") > 0 then
      	imgPath="GREEN"
      
      elseif Instr(request.Form("it"), "Family") > 0 then
      	imgPath="RED"
      else
      	imgPath="NIACE14"
      end if
      
      else
      	imgPath="NIACE14"
      end if
      
      %>
      
      <table  background="<%=imgPath%>.jpg" style="background-repeat:no-repeat" height="271px" width="362px" >
      <tr><td align="center" height="50px" style="font-size:meduim">&nbsp; </td> </tr>
      <tr><td align="center" height="30px" style="font-size:28px"><b><%=request.Form("it")%></b> </td> </tr>
      <tr><td align="center" valign="top" height="28x" style="font-size:larger"><%=request.Form("fn")%> </td> </tr>
      <tr><td align="center" valign="top" height="27px" style="font-size:larger"><%=request.Form("comp")%> </td> </tr>
      <tr><td align="center" height="20px" style="font-size:larger">&nbsp; </td> </tr>
      <tr><td align="center" style="font-size:18px;color:#000000"><%=request.Form("")%> </td> </tr>
      
      
      </table>
      <%end if%>
      
      
      </html>
      Last edited by Frinavale; Dec 18 '13, 07:48 PM. Reason: Removed list that made each line into a list item and added code tags around the code

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        So, did adding the function fix the error or are you still experiencing the same error??

        Comment

        • spenc
          New Member
          • Dec 2013
          • 3

          #5
          no it did not.
          what i want to achieve is to add a print all.

          Comment

          Working...