472,328 Members | 1,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

request.form can not get the select option field when it contains an apostrophe

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>
Jan 25 '07 #1
1 5426
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>
I've found a way to work around it. Thanks any way!
Jan 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the...
5
by: Raffi | last post by:
Hi folks, I'm new to JavaScript and need some help. I have a form with a select field. Depending on what is selected in this field, I want to...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three,...
2
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions...
8
by: Rabel | last post by:
I am new to asp and I am having a little trouble with the Request.form option. What I want to do is I have a dropdown box. <select...
5
by: phpCodeHead | last post by:
I am needing to determine how to go about validating that a field in my form contains only a positive integer. I know that this is fairly simple if...
1
by: tomlebold | last post by:
Having problems displaying query results from combo boxes on a sub form, which is on the same form that is used to select criteria. This has always...
2
dlite922
by: dlite922 | last post by:
Before traversing my code, here's what my goal is and what this function does: I have a table of fields that dynamically grows as the user enters...
8
by: NMarks | last post by:
Hello all, I have created a database for my work that stores information for keys/locks, doors and employees. Specifically the database...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.