#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Posts
    53
    Rep Power
    10

    Smile Preview the searc result in the same page as the form


    Hi

    I have two .asp pages. One holds the searh form and the second holds the asp code and also shows the result of the search. This works as two pages.

    My problem is that I need this to be one page. I need to have the search form on top and the result should show up below. But trying to integrate the two always gives me an error message.

    Here is the code from the pages:
    page1
    <form id="search" name="search" method="post" action="form2.asp">
    <p>
    <label>
    Org. nr.<br />
    <input type="text" name="org" id="org" />
    </label>
    </p>
    <p>
    <label>
    Resultat<br />

    </label>
    </p>
    <p>
    <label>
    <input type="submit" name="Hent" id="Hent" value="Hent" />
    </label>
    </p>
    </form>


    Page2 (form2.asp)
    Code:
    <%  
    Dim adOpenForwardOnly, adLockReadOnly, adCmdTable, adOpenStatic
    adOpenForwardOnly = 0
    adLockReadOnly = 1
    adOpenStatic = 3 
    adCmdTable = 2
    
    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    	objConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\home\studio36\www\Databaser\kunder.mdb;Persist Security Info=False"
    	
    Dim strSearch, strCriteria
    strSearch = Request.Form("org")
    
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.open "kunder", objConn, adOpenStatic, adLockReadOnly, adCmdTable
    
    strCriteria = "Org-nr='" & strSearch & "'"
    
    objRS.Find strCriteria
    
    If objRS.EOF Then 
    Response.write "Det finnes ikke informasjon om dette org.nr." & strSearch 
    	Else 
    Response.Write "<strong>Org. nr.:</strong>" & objRS("Org-nr") & "<br />" &_
    	  "<strong>Navn:</strong>" & objRS("Navn") & "<br />" &_
    	  "<strong>Tlf:</strong>" & objRS("Tlf") & "<br />" &_
    	  "<strong>Mobil:</strong>" & objRS("Mobil") & "<br />" &_
    	  "<strong>E-post:</strong>" & objRS("E-post") & "<br />"  
    	End if  
    objRS.Close
    objConn.Close
    Set objRS = Nothing
    Set objConn = Nothing
    %>
    Any help on combining these two would be greatly appreciated.

  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    Sounds like you want to use some ajax in your page, possibly by using jquery or similar.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Posts
    53
    Rep Power
    10

    Search form and result on the same page


    I am not very familiar with Ajax or Jquery. I have tried to put everything together in one page, and if you take a look at http://www.studio36.no/form20.asp , you will see the error just below the form. If you search for a organisation number like 940 060 192 you'll see the information below the form.

    This is just what I want. I just need to get the initial error message out of the way and I have no idea on how to do that.

    Here is the code from the page.

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <% option explicit %>
    
    <%  
    Dim adOpenForwardOnly, adLockReadOnly, adCmdTable, adOpenStatic
    adOpenForwardOnly = 0
    adLockReadOnly = 1
    adOpenStatic = 3 
    adCmdTable = 2
    
    Dim objConn, objRS
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    	objConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\home\studio36\www\Databaser\kunder.mdb;Persist Security Info=False"
    	'objConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\nina-saether\www\Databaser\kunder.mdb;Persist Security Info=False"
    	
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.open "kunder", objConn, adOpenStatic, adLockReadOnly, adCmdTable
    
    Dim strSearch, strCriteria
    strSearch = Trim(Replace(Request.Form("org"), "'", "''"))
    strSearch = Request.Form("org")
    strCriteria = "Org-nr='" & strSearch & "'"
    'strCriteria = strSearch 
    %>
    <!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=utf-8" />
    <title>bedriftsresevasjon</title>
    </head>
    
    <body>
    
    <form id="search" name="search" method="post" action="form20.asp">
      <p>
        <label>
          Org. nr.<br />
          <input type="text" name="org" id="org" />
        </label>
      </p>
      <p>
        <label>
          <input type="submit" name="Hent" id="Hent" value="Hent" />
        </label>
      </p>
    </form>
    <%  
    
    objRS.Find strCriteria 
    
    If objRS.EOF Then 
    Response.write "Det finnes ikke informasjon om dette org.nr." & strSearch 
    	Else 
    Response.Write "<strong>Org. nr.:</strong>" & objRS("Org-nr") & "<br />" &_
    	  "<strong>Navn:</strong>" & objRS("Navn") & "<br />" &_
    	  "<strong>Tlf:</strong>" & objRS("Tlf") & "<br />" &_
    	  "<strong>Mobil:</strong>" & objRS("Mobil") & "<br />" &_
    	  "<strong>E-post:</strong>" & objRS("E-post") & "<br />"  
    	End if  
    objRS.Close
    objConn.Close
    Set objRS = Nothing
    Set objConn = Nothing
    %>
    </body>
    </html>
    If you could please tell med where I went wrong I would be really greatful.

IMN logo majestic logo threadwatch logo seochat tools logo