ReportingAnalyst
MIS
I am not sure if this is the right place to ask this question. I am learning AJAX and interaction with ASP.
I am working on the Northwind database. I first show a select box with all the customers name.
Now the Javascript submits the CustomerID to the same page:
My question here is despite my select showing the 1st customer name, the query shows nothing for the querystring because I have not yet selected any value from the selectbox.
I get an error:
Incorrent syntax near =
It seems that it is not grabbing the 1st select box value into the SQL statement. How can I do that on load of the page?
Secondly, when I click on on a value of the select button, another select box is built right under it. Any ideas why I have a duplicate existence of the same select box?
Thanks.
I am working on the Northwind database. I first show a select box with all the customers name.
Code:
<form>
Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<%
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT CustomerID, CompanyName FROM Customers order by CompanyName"
rs.open sSQL, Conn
%>
<option VALUE="Select">Select Customers</option>
<%
While Not rs.EOF
%>
<option VALUE="<%=rs("CustomerID")%>"><%=rs("CompanyName")%></option>
<%
rs.MoveNext
wend
rs.close
set rs = nothing
%>
</select>
</form>
Code:
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;Data Source=DBServer;Initial Catalog=Northwind;"
%>
<html>
<head>
<script src="selectcustomer.js"></script>
</head>
<body>
<form>
Select a Customer:
<select name="customers" onchange="showCustomer(this.value)">
<%
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT CustomerID, CompanyName FROM Customers order by CompanyName"
rs.open sSQL, Conn
%>
<%
While Not rs.EOF
%>
<option VALUE="<%=rs("CustomerID")%>"><%=rs("CompanyName")%></option>
<%
rs.MoveNext
wend
rs.close
set rs = nothing
%>
</select>
</form>
<p>
<div id="txtHint"><b>Customer info will be listed here.</b>
<%
'Display the Customer Details.
sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
sql= sql & request.querystring("q")
Response.Write sql
Response.end
set rs1 = Server.CreateObject("ADODB.recordset")
rs1.Open sql, conn
response.write("<table>")
do until rs1.EOF
for each x in rs1.Fields
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")
next
rs.MoveNext
loop
response.write("</table>")
%>
</div>
</p>
</body>
</html>
I get an error:
Incorrent syntax near =
It seems that it is not grabbing the 1st select box value into the SQL statement. How can I do that on load of the page?
Secondly, when I click on on a value of the select button, another select box is built right under it. Any ideas why I have a duplicate existence of the same select box?
Thanks.