Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1

Thread: subform called

  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    50
    Thanks
    19
    Thanked 0 Times in 0 Posts

    subform called

    ok i was referenced over to here about ajax subform calling. (i was in asp)
    I need help doing a database subform call. I have everything working except for 1 major item. I don't know how to pass a database unique id variable from the combo box list to the other asp query page that displays the output. I have narrowed it down to when i choose an option it needs to post it to the variable in "xmlhttp.open("GET","getrequest.asp?q="+str,true);" right now its returning the line number of the combo box. But i have been trying for the past couple hours to modify it and i dont enough about java-script or ajax to do it. so im hoping someone knows enough how edit this to send the uniquie id of what i choose instead of the combo box line number. Thanks Guys in adb

    Code:
    
    <html>
    <head>
    <%
    *** this database calls all the variables to be put in the combo select list
    'Dimension variables
    Dim adoCon         'Holds the Database Connection Object
    Dim rsMakeReq    'Holds the recordset for the records in the database
    Dim strSQL         'Holds the SQL query to query the database
     	'Create an ADO connection object
    Set adoCon = Server.CreateObject("ADODB.Connection") 	
    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/mediadb.mdb") 	
    'Create an ADO recordset object
    Set rsMakeReq = Server.CreateObject("ADODB.Recordset") 	
    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT request.* FROM request;" 	
    'Open the recordset with the SQL query
    rsMakeReq.Open strSQL, adoCon
    if rsmakereq.eof = true then
    response.write ("No New Requests")
    else
     
    	id = (rsMakeReq("id"))
    	username = (rsMakeReq("username"))
    	ipaddress = (rsMakeReq("ipaddress"))
    	movieyear = (rsMakeReq("movieyear"))
    	movietitle = (rsMakeReq("movietitle"))
    	movieimdb = (rsMakeReq("movieimdb"))
    %>
    
    ** this is the ajax database script
    <script type="text/javascript">
    function showCustomer(str)
    {
    if (str=="")
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","getrequest.asp?q="+str,true);
    xmlhttp.send();
    }
    </script>
    </head
    <body>
    
    <form>
    ** ajax call
    <select name="customers" onchange="showCustomer(this.value)">
    <%Do While not rsMakeReq.EOF%>
    **fills in the unique id it pulls from the database
      <option value="<%Response.Write(rsMakeReq("id"))%>">
    ** fills in the username it pulls from the database
      <%Response.Write (rsMakeReq("Username"))%></option>
    	<%
    	'Move to the next record in the recordset   
    	rsMakeReq.MoveNext
    	Loop%>
      </select>
      </form>
    <br />
    <div id="txtHint">Customer info will be listed here...</div>
    <%
     	'Reset server objects
    	end if 
    rsMakeReq.Close
    Set rsMakeReq = Nothing
    Set adoCon = Nothing
    %>
    </body>
    </html>
    That was the main page the ** is what i added to help explain. if you have any questions just ask. But the Unique id i need sent over from this page to the other page below so it can get the correct information because right now it just grabs the first one it sees

    Code:
     	<%
    	Request.QueryString()
    response.expires=-1
    ** this is the select statment that gets the request the unique id is at the **end of the statement right now it has 61 which is just a test one because **it pulls the 61st object from the database. i need it to change dynamically **when i click on one of the options from the other page the string below takes the sql query and gets the variable  from the other page/the javascript/ajax 
    
    sql="SELECT request.* FROM request where request.ID=61"
    sql=sql & request.querystring("q") & ";"
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("/database/mediadb.mdb"))
    set rs=Server.CreateObject("ADODB.recordset")
    rs.Open sql,conn
    
    response.write("<table>")
    do until rs.EOF
      for each x in rs.Fields
      
        response.write("<td>" & x.value & "</td></tr>")
      next
      rs.MoveNext
    loop
    response.write("</table>")
    %>
    if you have any problems or questions just ask
    this is hopefully easy for you guys but i cant understand it. the only thing that i see, that it passes is the variable "str" i tried adding another one but its apparent i screwed that up because then it does nothing
    Last edited by nvysel24; 10-30-2010 at 08:50 AM.


 

Posting Permissions

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