469,917 Members | 1,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

ASP Case Statement Minor Issue

Hi Master CroCrew et All,

I am working on a CASE statement to allow different type of searches to search for different type of projects. EVERYTHING WORKS FINE EXCEPT, if the "Any Projects" radio button is checked and if the "All, Complete or Incomplete button is checked, it DISPLAYS everything fine. However, if the "Any Projects" radio button is checked and if the "Complete Projects Only" or "Incomplete Projects Only" button is checked IT DOES NOT DISPLAY ANYTHING. I don't see anything wrong with the DISPLAY.ASP file and wonder if you can use your EAGLE EYES to give me a hand here.

As always, YOU ARE THE BEST. Thanks.

This process includes 2 files. SearchProject-Testing.asp and DisplayProject-Testing.asp.

SearchProject-Testing.asp (This is where user select their search option).

table.MAIN { border: none; }
table.MAIN TR TD { font-size: small; font-family: helvetica, arial, sans serif; }
table.MAIN TR TH { font-size: small; font-family: helvetica, arial, sans serif; font-weight: bold;
width: 350px; text-align: right; }

var msgs = new Array("",
"Enter Project ID:",
"Enter Engineer's Name (or partial name):",
"Enter PM's Name (or partial name):");

function setInfo( )
var sts = document.xForm.SearchType;

// set message according to searchtype:
for ( var n = 0; n < sts.length; ++n )
if ( sts[n].checked ) document.getElementById("SLABEL").innerHTML = msgs[n];
document.getElementById("SBOX").style.visibility = sts[0].checked ? "hidden" : "visible";

<BODY BGCOLOR="#FFFFFF" onLoad="setInfo();">
<h2>Please Select Your Search:</h2>
<FORM NAME="xForm" METHOD="post" ACTION="DisplayProject-Testing.asp">
<TH align="right" valign="top">Type of Search:</TH>
<INPUT TYPE="radio" NAME="SearchType" VALUE="0" CHECKED onClick="setInfo()"> Any projects<br/>
<INPUT TYPE="radio" NAME="SearchType" VALUE="1" onClick="setInfo()"> By Project ID<br/>
<INPUT TYPE="radio" NAME="SearchType" VALUE="2" onClick="setInfo()"> By Engineer <br/>
<INPUT TYPE="radio" NAME="SearchType" VALUE="3" onClick="setInfo()"> By PM's Name<P>
<TH align="right" valign="top">Search for what kinds of projects?</TH>
<INPUT TYPE="radio" NAME="Completion" Value="A" CHECKED> All, complete or incomplete<br/>
<INPUT TYPE="radio" NAME="Completion" Value="C"> Completed projects only<br/>
<INPUT TYPE="radio" NAME="Completion" Value="N"> Incomplete (Open) projects only<P>
<TH valign="top" ID="SLABEL"></TH>
<TD ID="SBOX" style="visibility: hidden;">
<INPUT Name="SearchWith" Size="30"><p>
<TD><INPUT CLASS="Table_Blue" TYPE="submit" NAME="Submit" VALUE="SEARCH"></TD>

DisplayProject-Testing.asp (To display the search result).

strSearchType = trim(Request("SearchType"))
If Not IsNumeric(strSearchType) Then sType = 0 Else sType = CDBL(strSearchType)

strSearchWith = trim(Request("SearchWith"))
sqlSearchWith = "'%" & Replace(strSearchWith,"'","''") & "%'"

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("Database.mdb")

select case sType
case 0 : where = ""
case 1 : where = " WHERE RecordID=" & CLNG(strSearchWith)
case 2 : where = " WHERE Engineer LIKE " & sqlSearchWith
case 3 : where = " WHERE PMName LIKE " & sqlSearchWith
case else
Response.Redirect ("SearchProject-Testing.asp?error=Sorry ... Please enter a valid search type.")
end select

Select Case Trim(Request("Completion"))
CASE "C" : cCheck = " AND CompleteDate IS NOT NULL"
CASE "N" : cCheck = " AND CompleteDate IS NULL"
CASE ELSE : cCheck = ""
End Select

strSQL = "SELECT * FROM ProjectTable " & where & cCheck & " ORDER BY RecordID"

Set RS = Conn.Execute( strSQL )

If (RS.EOF) Then
Response.Redirect ("SearchProject-Testing.asp?error=Sorry ... Your Project ID does not exist in our database. Please try again.")
End If
...... HTML portion
Feb 9 '08 #1
1 1683
Hi All,

Please IGNORE. It works FINE now. Thanks.
Feb 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by digitalfish | last post: by
32 posts views Thread by Elliot Temple | last post: by
26 posts views Thread by Joe Stevenson | last post: by
10 posts views Thread by clueless_google | last post: by
3 posts views Thread by mark.irwin | last post: by
8 posts views Thread by | last post: by
18 posts views Thread by dspfun | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.