ASP Case Statement Minor Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hotflash
    New Member
    • Jan 2008
    • 85

    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).

    <HTML>
    <HEAD>
    <TITLE>Homepage </TITLE>
    <STYLE>
    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; }
    </STYLE>

    <SCRIPT>
    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.getEle mentById("SLABE L").innerHTM L = msgs[n];
    }
    document.getEle mentById("SBOX" ).style.visibil ity = sts[0].checked ? "hidden" : "visible";
    }
    </SCRIPT>

    </HEAD>
    <BODY BGCOLOR="#FFFFF F" onLoad="setInfo ();">
    <h2>Please Select Your Search:</h2>
    <FORM NAME="xForm" METHOD="post" ACTION="Display Project-Testing.asp">
    <TABLE class="MAIN" CELLSPACING="0" CELLPADDING="4" C>
    <TR>
    <TH align="right" valign="top">Ty pe of Search:</TH>
    <TD>
    <INPUT TYPE="radio" NAME="SearchTyp e" VALUE="0" CHECKED onClick="setInf o()"> Any projects<br/>
    <INPUT TYPE="radio" NAME="SearchTyp e" VALUE="1" onClick="setInf o()"> By Project ID<br/>
    <INPUT TYPE="radio" NAME="SearchTyp e" VALUE="2" onClick="setInf o()"> By Engineer <br/>
    <INPUT TYPE="radio" NAME="SearchTyp e" VALUE="3" onClick="setInf o()"> By PM's Name<P>
    </TD>
    </TR>
    <TR>
    <TH align="right" valign="top">Se arch for what kinds of projects?</TH>
    <TD>
    <INPUT TYPE="radio" NAME="Completio n" Value="A" CHECKED> All, complete or incomplete<br/>
    <INPUT TYPE="radio" NAME="Completio n" Value="C"> Completed projects only<br/>
    <INPUT TYPE="radio" NAME="Completio n" Value="N"> Incomplete (Open) projects only<P>
    </TD>
    </TR>
    <TR>
    <TH valign="top" ID="SLABEL"></TH>
    <TD ID="SBOX" style="visibili ty: hidden;">
    <INPUT Name="SearchWit h" Size="30"><p>
    </TD>
    </TR>
    <TR>
    <TD></TD>
    <TD><INPUT CLASS="Table_Bl ue" TYPE="submit" NAME="Submit" VALUE="SEARCH"> </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>

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

    <%
    strSearchType = trim(Request("S earchType"))
    If Not IsNumeric(strSe archType) Then sType = 0 Else sType = CDBL(strSearchT ype)

    strSearchWith = trim(Request("S earchWith"))
    sqlSearchWith = "'%" & Replace(strSear chWith,"'","''" ) & "%'"

    Set Conn = Server.CreateOb ject("ADODB.Con nection")
    Conn.Open "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & Server.MapPath( "Database.m db")

    select case sType
    case 0 : where = ""
    case 1 : where = " WHERE RecordID=" & CLNG(strSearchW ith)
    case 2 : where = " WHERE Engineer LIKE " & sqlSearchWith
    case 3 : where = " WHERE PMName LIKE " & sqlSearchWith
    case else
    Response.Redire ct ("SearchProj ect-Testing.asp?err or=Sorry ... Please enter a valid search type.")
    end select

    Select Case Trim(Request("C ompletion"))
    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.Redire ct ("SearchProj ect-Testing.asp?err or=Sorry ... Your Project ID does not exist in our database. Please try again.")
    End If
    %>
    ...... HTML portion
  • hotflash
    New Member
    • Jan 2008
    • 85

    #2
    Hi All,

    Please IGNORE. It works FINE now. Thanks.

    Comment

    Working...