I have the following code which will display what course I have selected. But if one of my course has an apostrophe, something like: teacher's test, the oRs("CourseName") will only show "teacher" instate of "teacher's test". Any one can help me to display the whole content: "teacher's test"? Thank you in advance!
<%@ Language=VBScript %>
<%Option explicit
Dim oRs, conn, connect, strSQL
set conn=server.CreateObject ("adodb.connection")
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("courses.mdb") & ";Persist Security Info=False"
conn.Open connect
%>
<html>
<head>
<title>Example combo box</title>
<script language="javascript">
<!--
function dept_onchange(frmSelect) {
frmSelect.submit();
}
//-->
</script>
</head>
<body>
The following was selected : <%=Request.Form ("courses")%>
<form name="frmSelect" method="Post" action="select.asp">
<SELECT name="courses" LANGUAGE="javascript" onchange="return dept_onchange(frmSelect)">
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT CourseName FROM tblCourses ORDER BY CourseName"
oRs.Open strSQL, conn
Do while not oRs.EOF
if Request.Form("courses") = oRs("CourseName") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRs ("CourseName") & "' SELECTED>"
Response.Write oRs("CourseName") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("CourseName") & "'>"
Response.Write oRs("CourseName") & "</Option>"
oRs.MoveNext
end if
loop
oRs.close
%>
</SELECT>
</form>
</body>
</html>