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 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post

    i dont get data results

    Hello i use a javascript in order to display data from my data page.
    At the moment the table is displayed but with no values need some help probably.
    Alo it would be great if there is a way using an if else statement to run a 2nd or a 3rd queri dipending on user inputs


    My main page (probably is right since i get table but with no values):

    Code:
    <!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>
    
    <script type="text/javascript">
    function showUser()
    {
    	if (window.XMLHttpRequest)
    	{// code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlhttp=new XMLHttpRequest();
    	} else {// code for IE6, IE5
    		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	var t=document.getElementById("type");
    	var t_val = t.options[t.selectedIndex].value;
    	var c_val = document.getElementById("checkin").value;
    	var r_val = document.getElementById("checkout").value;
    
    	 xmlhttp.onreadystatechange=function()
    	{
    		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    		}
    	}
    	 xmlhttp.open("GET","check11.asp?q=" + t_val + "&c=" + c_val+"&r=" +r_val, true);
    	 xmlhttp.send();
    }
    </script>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form action="">
    	<select id="type" onchange="showUser();">
    		<option value="">types</option>
    		<option value="single">single</option>
    		<option value="double">double</option>
    		<option value="suite">suits</option>
    	</select>
    	<input id="checkin"  onchange="showUser();" size="22"/>
    	<input id="checkout"  onchange="showUser();" size="22"/>
    </form>
    <br />
    <div id="txtHint">here...</div>
    </body>
    </html>
    my data page (need some help here i think):


    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="Connections/sqlconn.asp" -->
    <%
    Dim sql__MMColParam
    sql__MMColParam = "1"
    If (Request.Form("type") <> "") Then 
      sql__MMColParam = Request.Form("type")
    End If
    %>
    <%
    Dim sql
    Dim sql_cmd
    Dim sql_numRows
    
    Set sql_cmd = Server.CreateObject ("ADODB.Command")
    sql_cmd.ActiveConnection = MM_sqlconn_STRING
    sql_cmd.CommandText = "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and type='" & request.querystring("t") & "' and checkin >'" & request.querystring("c") & "' and checkout >'" & request.querystring("r") & "' and status='active' "
    sql_cmd.Prepared = true
    sql_cmd.Parameters.Append sql_cmd.CreateParameter("param1", 200, 1, 50, sql__MMColParam) ' adVarChar
    
    Set sql = sql_cmd.Execute
    sql_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = -1
    Repeat1__index = 0
    sql_numRows = sql_numRows + Repeat1__numRows
    %>
    <!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>Untitled Document</title>
    </head>
    
    <body>
    <table border="1" cellpadding="1" cellspacing="1">
      <tr>
        <td>id</td>
        <td>type</td>
        <td>image</td>
        <td>price</td>
        <td>details</td>
      </tr>
      <% While ((Repeat1__numRows <> 0) AND (NOT sql.EOF)) %>
        <tr>
          <td><%=(sql.Fields.Item("id").Value)%></td>
          <td><%=(sql.Fields.Item("type").Value)%></td>
          <td><%=(sql.Fields.Item("image").Value)%></td>
          <td><%=(sql.Fields.Item("price").Value)%></td>
          <td><%=(sql.Fields.Item("details").Value)%></td>
        </tr>
        <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      sql.MoveNext()
    Wend
    %>
    </table>
    </body>
    </html>
    <%
    sql.Close()
    Set sql = Nothing
    %>
    Thanks!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,084
    Thanks
    80
    Thanked 4,552 Times in 4,516 Posts
    See my answer in the JavaScript forum. You are returning an HTML *PAGE* and you should be returning only contents for the <div>.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,084
    Thanks
    80
    Thanked 4,552 Times in 4,516 Posts
    But to find out if your ASP code is working or not, just try hitting it directly from your brower.

    Just hit the url
    check11.asp?q=QQQ&c=CCC&r=RRR

    where QQQ, CCC, and RRR are reasonable values that you would expect to get from your HTML page.

    l
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post
    OK Eerything works ok now my data page look like this atm and its fine.
    Now i need a way to saying:


    Code:
    //if values t+c+r selected run this query
    
    
    sql_cmd.CommandText = "SELECT dbo.rooms.id, type, image, price, details FROM dbo.rooms,dbo.transactions WHERE dbo.rooms.id=dbo.transactions.roomid and type='" & request.querystring("t") & "' and '" & request.querystring("c") & "' not between checkin and checkout and '" & request.querystring("r") & "' not between checkin and checkout and status='active' "
    
    //else display message: complete all information

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,084
    Thanks
    80
    Thanked 4,552 Times in 4,516 Posts
    I don't understand what you are asking.

    The query looks okay to me. What else do you need?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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