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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not returning ticked items after clicking the show ticked button.

Status
Not open for further replies.

makumbi

Programmer
Mar 15, 2011
12
UG
1.Hi members help me modify this code so that it displays ticked items only .





<%@LANGUAGE="VBSCRIPT"%>
<%
Dim MM_library_STRING
MM_library_STRING = "dsn=LocalServer;uid=sula;pwd=sula;"
%>
<html>
<head>
<title>Da Search Results!</title>
</head>

<body>
<form name="form1" method="post" action="">
<%
Dim intPageCount, strsearch, intRecordCount, intPage, intRecord, intStart, intFinish, SqlJunk, sqljunk2,iResultsNum,sula,catego,myChkBoxes
catego= Request.Form("TypeSearch")
strsearch= Request.Form("DaInBox")
sula = Request.Form("DaInBox")
myPage = Request.Form("myPage")
<!-------------- ADDED THIS ----------------------------------------------->
myChkBoxes = Request.Form("chkBox")
'<!-------------- ADDED THIS ----------------------------------------------->

IF myPage = "" THEN
myPage=1
END IF
IF Request.QueryString("mySQLStmt") <> "" THEN
'Need to Reconstruct the SQL Statement - Must have been submitted via a form
SqlJunk = Request.QueryString("mySQLStmt")
SqlJunk = replace( SqlJunk, "%25", "%")
SqlJunk = replace( SqlJunk, "!25!", "'")
SqlJunk = Replace( SqlJunk, "%20", " ")
IF myChkBoxes <> "" THEN
SqlJunk = SqlJunk + " WHERE checks in("& myChkBoxes &")"
END IF
ELSE
'Constrcuting new SQL First time we have been here
'sqljunk2= "UPDATE Employees SET Employees.Phone = '0782911364'"
SqlJunk = "SELECT * FROM booksd"
If Request.Form("TypeSearch") = "Title" Then
SqlJunk = SqlJunk & " WHERE title LIKE '%" & Request.Form("DaInBox") & "%'"
End If

If Request.Form("TypeSearch") = "Author" Then
SqlJunk = SqlJunk & " WHERE Author LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If

If Request.Form("TypeSearch") = "Shelve" Then
SqlJunk = SqlJunk & " WHERE Shelve LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If

If Request.Form("TypeSearch") = "Phrases" Then
SqlJunk = SqlJunk & " WHERE Phrases LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If

If Request.Form("TypeSearch") = "Callno" Then
SqlJunk = SqlJunk & " WHERE Callno LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If
end if

'Set variables and open the record
Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")
Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.ConnectionString =MM_library_STRING
dbGlobalWeb.Open
rsGlobalWeb.CursorLocation = 3 'adUseClient
rsGlobalWeb.CursorType = 3 'adOpenStatic
'rsGlobalWeb.mode = 3 ' adModeReadWrite
rsGlobalWeb.ActiveConnection = dbGlobalWeb
'rsGlobalWeb.open "sendinquiry",dbGlobalWeb
rsGlobalWeb.Open Sqljunk
If NOT rsGlobalWeb.eof THEN
'We must have found some records
g_search="obs found"
rsGlobalWeb.movefirst

' Sets the number of observations per page to a max of 10
rsGlobalWeb.pagesize=30
' Set the pageCount of records are we in ?
rsGlobalWeb.absolutepage=myPage
' Get the total Number of Pages based on our PagesSize
myPageCount = rsGlobalWeb.pagecount

WITH RESPONSE
iResultsNum = ((myPage - 1) * rsGlobalWeb.pagesize)
' Go throug and list all the records
.Write "<TABLE>" &vbCRLF
.Write " <TR>" &vbCRLF
'THIS IS NEW COLUMN
.Write " <TD valign=top><span class='style4'><strong>Tick.</strong></span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style4'><strong>No.</strong></span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style4'><strong>Title</strong> </span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style4'><strong>Call No</strong> </span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style4'><strong>Author</strong> </span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style4'><strong>Subject</strong> </span></TD>" &vbCRLF
.Write " <TD valign=top>&nbsp;</TD>" &vbCRLF
.Write " </TR>" &vbCRLF
DO WHILE NOT rsGlobalWeb.eof and numofobs < rsGlobalWeb.pagesize
.Write " <TR>" &vbCRLF
.Write " <TR>" &vbCRLF
'THIS IS NEW LINE
iResultsNum = iResultsNum + 1
.Write " <TD valign=top><span class='style5'><input type='checkbox' name='chkBox' value=' "& rsGlobalWeb("checks") &"'></span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style5'>"& iResultsNum &"</span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style5'>"& rsGlobalWeb("title") &"</span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style5'>"& rsGlobalWeb("callno") &"</span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style5'>"& rsGlobalWeb("author") &"</span></TD>" &vbCRLF
.Write " <TD valign=top><span class='style5'>"& rsGlobalWeb("category") &"</span></TD>" &vbCRLF
.Write " <TD valign=top>&nbsp;</TD>" &vbCRLF
.Write " </TR>" &vbCRLF
.Write " <TR><TD Colspan='3'> </TD></TR>"&vbCRLF
rsGlobalWeb.movenext
' Counts the number of observations in the current page
numofobs=numofobs+1
LOOP
rsGlobalWeb.Close
dbGlobalWeb.Close
.Write "</TABLE>" &vbCRLF &vbCRLF
.Write "<input type='submit' value='ShowChk' name='bSubmit'>" &vbCRLF
.Write "</TABLE>" &vbCRLF &vbCRLF
.Write "</FORM>"
END WITH 'Response

'Prepare the SQL Statement for HTML TRANSPORT
'Used for Like
myHTMLSQLJunk = replace(SqlJunk, "%", "%25")
'USed for Dates
'myHTMLSQLJunk = replace(myHTMLSQLJunk, "#", "SOMECODEHERE")
'used for text
myHTMLSQLJunk = replace(myHTMLSQLJunk, "'", "!25!")
'Used for Spaces
myHTMLSQLJunk = replace(myHTMLSQLJunk, " ", "%20")

With Response
.Write "<TABLE><TR><TD>"
IF int(myPage) > 1 THEN
.Write "<form method='post' action='"& request.servervariables("script_name")&"?mySQLStmt="& myHTMLSQLJunk &"'>" &vbCRLF
.Write "<input type='hidden' name='myPage' value='"& myPage - 1 &"'>" &vbCRLF
'.Write "<input type='hidden' name='mySQLJunk' value='"& myHTMLSQLJunk &"'>" &vbCRLF
.Write "<input type='hidden' name='DaInBox' value='"& DaInBox &"'>" &vbCRLF
.Write "<input type='submit' value='<'>" &vbCRLF
.Write "</form></TD><TD>" &vbCRLF &vbCRLF
END IF

.Write " <form method='post' action='"& request.servervariables("script_name")&"?mySQLStmt="& myHTMLSQLJunk &"'>" &vbCRLF
.Write " <input type ='hidden' name='DaInBox' value='"& strsearch &"'>" &vbCRLF
.Write " <select name='myPage' size='1' onchange='this.form.submit();' name='bSubmit'>" &vbCRLF

' Starts loop from one to the maximum number of pages
For counter=1 to myPageCount
' This will select the current page in the dropdown menu
if cint(myPage) = cint(counter) then
.Write "<Option Selected value="& counter &">Page "& counter &" of "& myPageCount &"</option>" &vbCRLF
ELSE
.Write "<Option value="& counter &">Page "& counter &" of "& myPageCount &"</option>" &vbCRLF
END IF
Next
.Write "</select>" &vbCRLF
.Write "</form></TD><TD>" &vbCRLF &vbCRLF

IF int(myPage) < int(myPageCount) THEN
.Write "<form method='post' action='"& request.servervariables("script_name")&"?mySQLStmt="& myHTMLSQLJunk &"'>" &vbCRLF
.Write "<input type='hidden' name='myPage' value='"& myPage + 1 &"'>" &vbCRLF
'.Write "<input type='hidden' name='mySQLJunk' value='"& myHTMLSQLJunk &"'>" &vbCRLF
.Write "<input type='hidden' name='DaInBox' value='"& DaInBox &"'>" &vbCRLF
.Write "<input type='submit' value='>'>" &vbCRLF
.Write "</form>" &vbCRLF
END IF
.Write "</TD></TR></TABLE>" &vbCRLF
'.Write "<P>"& numofobs &" Results displayed on this page For Category Search <br></P> " &vbCRLF
'.Write "<P>"& sula &" Is The Category search <br></P> " &vbCRLF
END WITH 'Response
End IF ' Not EOF

'We Did not Find Records and We actually tried looking for them
IF g_search <> "obs found" AND DaInBox <> "" THEN
response.write "Nothing reults found for your search on <i>"& DaInBox &"</i><br>"
END IF
%>
</form>
<table width="430" border="2" cellpadding="2" cellspacing="2">
<tr>
<th width="202" scope="col">Your Searched Key Word = </th>
<th width="193" scope="col"><strong><%=sula%></strong>&nbsp;</th>
</tr>
<tr>
<th scope="row"><strong>Category Searched</strong> = </th>
<th width="193" scope="col"><strong><%=catego%></strong>&nbsp;</th>
</tr>
<tr>
<th scope="row">Total Results Disaplayed </th>
<td><div align="center"><strong><%=numofobs%></strong></div></td>
</tr>
</table>
<a href="ASPSearch.asp">NEW SEARCH</a>
 
What does the form look like on the client side? Does it have a value= on the checkbox?

Note that you will only get something if the checkbox is checked.
 
The items are clicked on the interface but when i click on the display menu it doesnt diplay any of the items ticked
 
Change this bit
Code:
.Write " <TD valign=top><span class='style5'><input type='checkbox' name='chkBox' value=' "& rsGlobalWeb("checks")
if myChkBoxes <> "" then
   .Write " checked"
end if
.Write "'></span></TD>" &vbCRLF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top