View Single Post
  #9 (permalink)  
Old May 6th, 2008, 02:42 PM
MarkGT MarkGT is offline
Authorized User
Join Date: Apr 2008
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

Ok, I sort of figured this out. Below is a piece of code from my page. I have three separate select boxes that populate another select box, based on the selection from the first. I posted code for only one. The select boxes work fine. I need to get the values from the selections into an sql statement.

below is the code for one of my <select> lists
<select name="classyear" onChange="showYear()">
<option value="0">Choose year</option>

while not objrs.eof%>
<option value="<%=objrs("class")%>"><%=objrs("class")%></option>

while not objrs.eof%>

<div id="<%=objrs("class")%>menu">
<select name="<%=objrs("class")%>month">

strSQL = "SELECT distinct classmd from s6test where class='" & objrs("class") & "'"
set objrs1=objconn.execute(strSQL)
   while not objrs1.eof

   <option value="<%=objRS1("classmd")%>"><%=objRS1("classmd")%></option>



wend %>
Here is the code for my sql statement:
wsql = " SELECT Count(Emp_ID) AS [numberfirstpasses] FROM S6Test where Score1>70 
AND class='"&classyear&"' AND classmd= '"&objrs("class")&"'&'&month&';"
set rs10 = objconn.execute (wSql)
The name of my second select box (that populates based on selections from the first) is dynamic. It's the bold portion of code above. I don't get any errors when I run this sql statement, but it doesn't return the correct result. It returns "0" when it should return "4." I assume it has to have something to do with the syntax of the <select> box values in the sql statement. Does anyone see a problem with the sql statement?

NOTE: The sql statement is one line in my asp page, I entered a return in the code above just to make it easier to read. The "month" at the end of the "<select name="<%=objrs("class")%>month">" is necessary because I use month, montha and monthb to differentiate between the three select lists.
Reply With Quote