I have an asp program using a drop down menu. For the record in question(I am hardcoding for testing purposes) 2 detail records should be returned. This part is correct.
However because of the way I used coding to populate the drop down menu field(TopicCatagory), I am getting the same value for this field for both detail records. In the database the value for TopicCatagory is different. All other fields that are below are correct.
MeetingDetails ID MeetingID TopicCatagory Notes
20 27 ROP AVON
21 27 ROP RELAY
Where it should be
MeetingDetails ID MeetingID TopicCatagory Notes
20 27 ROP AVON
21 27 PSC RELAY
Below is my code.
--
--<%
OPTION EXPLICIT
'//application variables
dim strSql, db, pcRS, objRs
'//ASSIGN app VALUES
Set db = Server.CreateObject("ADODB.Connection"
db.Open "DBQ=" & Server.MapPath("polk.mdb"
& ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;", "username", "password"
Set pcRS = Server.CreateObject("ADODB.Recordset"
Set objRs = Server.CreateObject("ADODB.Recordset"
'//do stuff
strSql = "SELECT mt_id, meeting_id, topic_cat_id, topic_id, notes FROM meeting_details WHERE meeting_id = 27 "
pcRS.Open strSql, db
'//meeting variables
dim meeting_id, topic_cat_id
'//init meeting variables
topic_cat_id = pcRS("topic_cat_id"
meeting_id = ""
%>
<HTML>
<HEAD>
<TITLE>DropDown Menu</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function submissionHandler(p_oSelWhere) {
// notice the 2 different techniques you can use to do the same thing
if (document.forms[0].topic_cat_id.options[document.forms[0].topic_cat_id.selectedIndex].text == "-- Select Topic --"
{
//if (p_oSelWhere.options[p_oSelWhere.selectedIndex].text == "-- Select Topic --"
{
alert("Please Select a Topic Category."
;
} else {
// 2 techniques doing the same thing
document.forms[0].topic_catagory.value = p_oSelWhere.options[p_oSelWhere.selectedIndex].text
//document.forms[0].topic_catagory.value = document.forms[0].topic_cat_id.options[document.forms[0].topic_cat_id.selectedIndex].text
document.forms[0].submission.value = "TRUE"
document.forms[0].target = "_self"
document.forms[0].action = "polk.asp"
document.forms[0].submit()
}
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#97AACF">
<FORM ID=form1 NAME=form1 METHOD="POST" ACTION="polk.asp">
<INPUT TYPE="HIDDEN" name="submission" ID="submission" VALUE="">
<INPUT TYPE="HIDDEN" name="topic_catagory" ID="topic_catagory" VALUE="">
<%
'//ADDED THIS TO LOOP THROUGH POSSIBLE MULTIPLE DETAIL RECORDS
'//CORRECT EXCEPT TOPIC_CAT_ID IS THE SAME VALUE
'//RECORD WITH MT_ID 20 -> TOPIC_CATAGORY IS REPORT OF THE PRINCIPAL
'//RECORD WITH MT_ID 21 -> TOPIC_CATAGORY IS PRESENTATION TO THE SCHOOL COUNCIL
'Loop through the recordset
Do While not pcRS.EOF
%>
<center>
<table border=2 width=600>
<TR>
<TD>
Meeting Details ID
</TD>
<TD>
Meeting ID
</TD>
<TD>
Topic Catagory
</TD>
<TD>
Notes
</TD>
</TR>
<TR>
<TD>
<input type="text" name="mt_id" maxlength="4" size=4 value="<% = pcRS("mt_id"
%>">
</TD>
<TD>
<input type="text" name="meeting_id" maxlength="4" size=4 value="<% = pcRS("meeting_id"
%>">
</TD>
<TD>
<%
'//BEGIN TOPIC DROPDOWN
strSql = "SELECT topic_cat_id, topic_catagory FROM topic_catagory"
SET objRs = db.Execute(strSql) '//grab data
'//-topic_id is the NAME/ID of this form element...its VALUE will be the topic_cat_id of the selected topic...the
'// user can't see this'//-the TEXT of this form element will be what the user see's ...the topic_catatory
Response.Write("<select name='topic_cat_id' id='topic_cat_id' size=1 ONCHANGE='submissionHandler(this)'>"
do while not objRs.EOF
if topic_cat_id = objRs("topic_cat_id"
then '//here is where you check with the "other" recordset...the meeting
Response.Write("<option value='" & TRIM(objRs("topic_cat_id"
) & "' selected>" & TRIM(objRs("topic_catagory"
) & "</option>"
else
Response.Write("<option value='" & TRIM(objRs("topic_cat_id"
) & "'>" & TRIM(objRs("topic_catagory"
) & "</option>"
end if
objRs.Movenext
loop
Response.Write("</select>"
'//END TOPIC DROPDOWN
Response.Write("<br><br>"
'Response.Write("<strong>Request Object Values</strong><br><br>"
'Response.Write("Topic Category: " & request("topic_catagory"
& "<br>"
'Response.Write("Topic ID: " & request("topic_cat_id"
)
%>
</TD>
<TD>
<input type="text" name="notes" maxlength="60" size=20 value="<% = pcRS("notes"
%>">
</TD>
</TR>
</table>
</center>
<%
'Move to the next record in the recordset
pcRS.MoveNext
Loop
%>
</form>
</BODY>
</HTML>
--
--
If anyone can point out where I messed up I would so much appreciate it. I could also email the db.
Thank you very much and please everyone have a happy and safe Thanksgiving!
PamPolk
However because of the way I used coding to populate the drop down menu field(TopicCatagory), I am getting the same value for this field for both detail records. In the database the value for TopicCatagory is different. All other fields that are below are correct.
MeetingDetails ID MeetingID TopicCatagory Notes
20 27 ROP AVON
21 27 ROP RELAY
Where it should be
MeetingDetails ID MeetingID TopicCatagory Notes
20 27 ROP AVON
21 27 PSC RELAY
Below is my code.
--
--<%
OPTION EXPLICIT
'//application variables
dim strSql, db, pcRS, objRs
'//ASSIGN app VALUES
Set db = Server.CreateObject("ADODB.Connection"

db.Open "DBQ=" & Server.MapPath("polk.mdb"

Set pcRS = Server.CreateObject("ADODB.Recordset"

Set objRs = Server.CreateObject("ADODB.Recordset"

'//do stuff
strSql = "SELECT mt_id, meeting_id, topic_cat_id, topic_id, notes FROM meeting_details WHERE meeting_id = 27 "
pcRS.Open strSql, db
'//meeting variables
dim meeting_id, topic_cat_id
'//init meeting variables
topic_cat_id = pcRS("topic_cat_id"

meeting_id = ""
%>
<HTML>
<HEAD>
<TITLE>DropDown Menu</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function submissionHandler(p_oSelWhere) {
// notice the 2 different techniques you can use to do the same thing
if (document.forms[0].topic_cat_id.options[document.forms[0].topic_cat_id.selectedIndex].text == "-- Select Topic --"

//if (p_oSelWhere.options[p_oSelWhere.selectedIndex].text == "-- Select Topic --"

alert("Please Select a Topic Category."

} else {
// 2 techniques doing the same thing
document.forms[0].topic_catagory.value = p_oSelWhere.options[p_oSelWhere.selectedIndex].text
//document.forms[0].topic_catagory.value = document.forms[0].topic_cat_id.options[document.forms[0].topic_cat_id.selectedIndex].text
document.forms[0].submission.value = "TRUE"
document.forms[0].target = "_self"
document.forms[0].action = "polk.asp"
document.forms[0].submit()
}
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#97AACF">
<FORM ID=form1 NAME=form1 METHOD="POST" ACTION="polk.asp">
<INPUT TYPE="HIDDEN" name="submission" ID="submission" VALUE="">
<INPUT TYPE="HIDDEN" name="topic_catagory" ID="topic_catagory" VALUE="">
<%
'//ADDED THIS TO LOOP THROUGH POSSIBLE MULTIPLE DETAIL RECORDS
'//CORRECT EXCEPT TOPIC_CAT_ID IS THE SAME VALUE
'//RECORD WITH MT_ID 20 -> TOPIC_CATAGORY IS REPORT OF THE PRINCIPAL
'//RECORD WITH MT_ID 21 -> TOPIC_CATAGORY IS PRESENTATION TO THE SCHOOL COUNCIL
'Loop through the recordset
Do While not pcRS.EOF
%>
<center>
<table border=2 width=600>
<TR>
<TD>
Meeting Details ID
</TD>
<TD>
Meeting ID
</TD>
<TD>
Topic Catagory
</TD>
<TD>
Notes
</TD>
</TR>
<TR>
<TD>
<input type="text" name="mt_id" maxlength="4" size=4 value="<% = pcRS("mt_id"

</TD>
<TD>
<input type="text" name="meeting_id" maxlength="4" size=4 value="<% = pcRS("meeting_id"

</TD>
<TD>
<%
'//BEGIN TOPIC DROPDOWN
strSql = "SELECT topic_cat_id, topic_catagory FROM topic_catagory"
SET objRs = db.Execute(strSql) '//grab data
'//-topic_id is the NAME/ID of this form element...its VALUE will be the topic_cat_id of the selected topic...the
'// user can't see this'//-the TEXT of this form element will be what the user see's ...the topic_catatory
Response.Write("<select name='topic_cat_id' id='topic_cat_id' size=1 ONCHANGE='submissionHandler(this)'>"

do while not objRs.EOF
if topic_cat_id = objRs("topic_cat_id"

Response.Write("<option value='" & TRIM(objRs("topic_cat_id"



else
Response.Write("<option value='" & TRIM(objRs("topic_cat_id"



end if
objRs.Movenext
loop
Response.Write("</select>"

'//END TOPIC DROPDOWN
Response.Write("<br><br>"

'Response.Write("<strong>Request Object Values</strong><br><br>"

'Response.Write("Topic Category: " & request("topic_catagory"


'Response.Write("Topic ID: " & request("topic_cat_id"

%>
</TD>
<TD>
<input type="text" name="notes" maxlength="60" size=20 value="<% = pcRS("notes"

</TD>
</TR>
</table>
</center>
<%
'Move to the next record in the recordset
pcRS.MoveNext
Loop
%>
</form>
</BODY>
</HTML>
--
--
If anyone can point out where I messed up I would so much appreciate it. I could also email the db.
Thank you very much and please everyone have a happy and safe Thanksgiving!
PamPolk