CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    1

    Search Function Not Working

    My 1st post - be gentle! My search function works properly on IE8 but when I use it on Firefox I get no results and I am not sure why this is! A search for "Glee" returns 6 items on IE8 but none on Firefox (& I believe Safari too). I'm not sure if the problem is the code or perhaps in the html later in the page. Thank you one & all for any help!

    Here is the code:

    <%@ Language=VBScript %>
    <% Option Explicit
    Response.Buffer = True
    Response.Expires=0 ' This specifies how long the client will cache the page
    'Response.Write "form=" & Request.Form & "<br>"
    ' *********************************************************************
    ' * Name: Search.asp
    ' *
    ' * Purpose:
    ' *
    ' * Date Created Programmer Purpose
    ' * 03/25/2004 Vaishali Goyal Search Catalog
    ' *********************************************************************
    '-----------------------------------------------------------

    '-----------------------------------------------------------
    ' --- Declare variables
    '-----------------------------------------------------------
    Dim scriteria
    Dim dataConn
    Dim recSet1,recSet
    Dim SQLStmt
    Dim fieldsimagename
    Dim fieldsshortdesc
    Dim fieldssize
    Dim fieldsimagewidth
    Dim fieldsimageheight
    Dim fieldsid
    Dim fieldscolor
    Dim i
    Dim widthstart
    Dim widthend
    Dim Lscriteria
    Dim fieldsinventoryid

    Main() ' Call the main subroutine

    '--- Main subroutine
    Sub Main()
    InitVariables() ' Initilize varibles
    GetDataFromDB()
    DisplayPageHeader()
    DisplayPageDetails()
    DisplayPageFooter()
    end sub

    sub InitVariables()
    'scriteria = Trim(Request("criteria"))
    scriteria = Trim(Request("search"))
    'Response.Write scriteria & "<br>"
    widthstart = InStr(UCase(scriteria), "WIDTH")
    widthend = widthstart + 5
    if cint(widthstart) = 0 then
    scriteria = scriteria
    else
    if widthstart = 1 then
    'Response.Write "right"
    Lscriteria = Len(scriteria)
    scriteria = Trim(Right(UCase(scriteria),(Lscriteria - widthend)))
    else
    'Response.Write "left"
    scriteria = Trim(Left(UCase(scriteria),(widthstart-1)))
    end if
    end if

    end sub

    sub GetDataFromDB()
    'SQLStmt = "SELECT distinct(i.imagename),i.shortdesc,i.sizes,i.colors,i.imagewidth,i.imageheight,c.id,i.id FROM category c,inventory i WHERE c.id = i.category "&_
    '" AND (c.shortdesc LIKE '%" &scriteria& "%' OR i.colors LIKE '%" &scriteria& "%' OR i.shortdesc LIKE '%" &scriteria& "%') and i.assignedassociate = 1 "&_
    '" and i.visiblehidden = 1 order by i.imagename"

    '===open connection
    set dataConn = Server.CreateObject("ADODB.Connection")
    dataConn.ConnectionString = session("Data_Connection_String")
    dataConn.Open

    Set recSet1 = Server.CreateObject( "ADODB.RecordSet" )

    SQLStmt = "SELECT distinct(i.imagename),i.shortdesc,i.sizes,i.colors,i.imagewidth,i.imageheight,c.id As CatID,i.id As InvID, C.itemsacross FROM "&_
    " category c,inventory i WHERE c.id = i.category "&_
    " AND (c.shortdesc LIKE '%" &scriteria& "%' OR i.colors LIKE '%" &scriteria& "%' OR i.shortdesc LIKE '%" &scriteria& "%') and c.vendor = 8 "&_
    " and c.visiblehidden = 0 order by i.imagename"


    'Response.Write SQLStmt
    'Response.End
    recSet1.CursorLocation = 3
    recSet1.Open SQLStmt, dataConn, 2, 4


    end sub

    Sub DisplayPageHeader()%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Search Our Catalog | Prom Shoes Boutique</title>
    <meta name="keywords" content="" />
    <meta name="description" content="Prom Shoes Boutique catalog search. Search for evening, bridesmaid and prom shoes" />
    <meta name="robots" content="index,follow" />
    <meta name="revisit-after" content="7 days" />

    <link href="style_promNEW.css" rel="stylesheet" type="text/css" />
    </head>

    <body>

    <script type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    function Validate(){
    if (document.searchcatalog.criteria.value == "") {
    alert("The field -Search- cannot be left blank.")
    document.searchcatalog.criteria.focus()
    return(false)
    }
    }
    //-->
    </script>

    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">

    <tr>
    <td><a href="index.asp"><img src="nav_images/banner_top.jpg" alt="Prom Shoes Boutique.com - Search Our Catalog" width="800" height="96" border="0" /></a></td>
    </tr>
    </table>

    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr><td><img src="nav_images/bar_btm.gif" width="800" height="13" /></td></tr>
    </table>

    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td bgcolor="#720B54">

    <table width="800" align="center" border="0" cellpadding="0" cellspacing="0">

    <tr>
    <td width="96" align="center" height="24"><a href="prom-shoes-catalog.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('cat','','nav_images/bt_cat2.gif',1)"><img src="nav_images/bt_cat.gif" title="View Entire Catalog" alt="View Entire Catalog" name="cat" width="96" height="24" border="0" id="cat" /></a></td>
    <td width="96" align="center" height="24"><a href="shipping.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('shipping','','nav_images/bt_shipping2.gif',1)"><img src="nav_images/bt_shipping.gif" title="Shipping Information" alt="Shipping Information" name="shipping" width="96" height="24" border="0" id="shipping" /></a></td>
    <td width="61" align="center" height="24"><a href="return.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('return','','nav_images/bt_return2.gif',1)"><img src="nav_images/bt_return.gif" title="Return Information" alt="Return Information" name="return" width="61" height="24" border="0" id="return" /></a></td>
    <td width="96" align="center" height="24"><a href="gen.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('gen','','nav_images/bt_gen2.gif',1)"><img src="nav_images/bt_gen.gif" title="General Information" alt="General Information" name="gen" width="96" height="24" border="0" id="gen" /></a></td>
    <td width="96" align="center" height="24"><a href="contact.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','nav_images/bt_contact2.gif',1)"><img src="nav_images/bt_contact.gif" title="Contact Information" alt="Contact Information" name="contact" width="96" height="24" border="0" id="contact" /></a></td>
    <td width="96" align="center" height="24"><a href="index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','nav_images/bt_home2.gif',1)"><img src="nav_images/bt_home.gif" title="Home Page" alt="Home Page" name="home" width="96" height="24" border="0" id="home" /></a></td>
    <td width="96" align="center" height="24"><a href="shopcart.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('cart','','nav_images/bt_cart2.gif',1)"><img src="nav_images/bt_cart.gif" title="Shopping Cart" alt="Shopping Cart" name="cart" width="96" height="24" border="0" id="cart" /></a></td>
    <td width="22" align="right"><form name="search" method="post" action="search.asp">
    <img src="nav_images/search_icon.gif" alt="Search Our Catalog" />
    </td>

    <td width="88" align="right" valign="middle">
    <input name="search" type="text" id="search" />
    </td>

    <td width="23" height="24" align="right"><a href="search.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('go_bt','','nav_images/bt_go3.gif',1)">
    <!--img src="nav_images/bt_go1.gif" name="go_bt" width="21" height="24" border="0" id="go_bt" /-->
    <input type="image" src="nav_images/bt_go1.gif" title="Search Catalog" alt="Search Catalog" name="go_bt" align="middle" id="go_bt" onclick="document.search.submit();" /></a></td></form>

    </tr>
    </table>

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Search Function Not Working

    Because JavaScript is not JAVA?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured