HarryGreiner
12-08-2005, 05:03 PM
I'm having a problem sorting out what I'm sure is a simple problem:
I have a small form which pulls a course title from a database of courses and puts it into a drop down box .... so far, so good.
<input name="stitle" type="hidden" id="stitle" value="title" onFocus="this.blur()"><SELECT name="entry">
<option value="">Select Course from here</option>
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT title FROM Courselist ORDER BY title"
oRs.Open strSQL, conn
Do while not oRs.EOF
Response.Write "<OPTION VALUE = '" & oRs ("title") & "'>"
Response.Write oRs("title") & "</Option>"
oRs.MoveNext
loop
%>
</SELECT>
Okay. So far, so good. That all works a treat.
Now, when the user submits this little form it goes to an asp page which extrapolates the data for that course into another form to be amended and corrected - here's a chunk of it below:
<%
Dim SqlJunk
Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../scripts2/courses2005/courses.mdb")
SqlJunk = "SELECT * FROM courselist"
If Request.Form("stitle") = "title" Then
SqlJunk = SqlJunk & " WHERE title LIKE '%" & Request.Form("entry") & "%' ORDER BY Title"
End If
Set rsWebsite = Server.CreateObject("ADODB.Recordset")
rsWebsite.Open SqlJunk, dbGlobalWeb, 3
%>
<%
If rsWebsite.BOF and rsWebsite.EOF Then%>
<h2 align="center">We did not find a match!<br>Click <a href="coursesearch.asp">here</a> to try a new search</h2>
<%Else%>
<%If Not rsWebsite.BOF Then%>
<%
Do While not rsWebsite.EOF
'Write the HTML to display the current record in the recordset
Response.Write ("<div><span>Course Title</span><input name=Course Title type=text size=92 value=")
Response.Write (rsWebsite("title"))
Response.Write ("></div><div><span>School</span><input name=school type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("school"))
Response.Write ("></div><div><span>What level is this course</span><input name=Course Level type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("level"))
Response.Write ("></div><div><span>How long does the course last?</span><input name=Course lasts for type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("lastsfor"))
Response.Write ("></div>")
'Move to the next record in the recordset
rsWebsite.MoveNext
Loop
%>
<%End If%>
<%End If%>
<%
rsWebsite.Close
dbGlobalWeb.Close
%>
Again, all seems to work just dandy EXCEPT FOR ONE THING ... where the course or school or whatever is more than one word (and most of them are) it doesn't display the rest of the words in the text box - only the first word shows up. If you look in the code of the document the words are there - they just don't show up in the text box! If you send the data through and have it land in a div or whatever (as plain text) it all shows up fine.
Can anybody PLEASE enlighten me as to why it's doing this and I'd be extreely grateful if you could tell me how to fix it!
Many, many thanks - I'm not an asp man (cobbled the above together from a couple of different scripts and got it working ... well, most of it anyway).
I have a small form which pulls a course title from a database of courses and puts it into a drop down box .... so far, so good.
<input name="stitle" type="hidden" id="stitle" value="title" onFocus="this.blur()"><SELECT name="entry">
<option value="">Select Course from here</option>
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT title FROM Courselist ORDER BY title"
oRs.Open strSQL, conn
Do while not oRs.EOF
Response.Write "<OPTION VALUE = '" & oRs ("title") & "'>"
Response.Write oRs("title") & "</Option>"
oRs.MoveNext
loop
%>
</SELECT>
Okay. So far, so good. That all works a treat.
Now, when the user submits this little form it goes to an asp page which extrapolates the data for that course into another form to be amended and corrected - here's a chunk of it below:
<%
Dim SqlJunk
Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../scripts2/courses2005/courses.mdb")
SqlJunk = "SELECT * FROM courselist"
If Request.Form("stitle") = "title" Then
SqlJunk = SqlJunk & " WHERE title LIKE '%" & Request.Form("entry") & "%' ORDER BY Title"
End If
Set rsWebsite = Server.CreateObject("ADODB.Recordset")
rsWebsite.Open SqlJunk, dbGlobalWeb, 3
%>
<%
If rsWebsite.BOF and rsWebsite.EOF Then%>
<h2 align="center">We did not find a match!<br>Click <a href="coursesearch.asp">here</a> to try a new search</h2>
<%Else%>
<%If Not rsWebsite.BOF Then%>
<%
Do While not rsWebsite.EOF
'Write the HTML to display the current record in the recordset
Response.Write ("<div><span>Course Title</span><input name=Course Title type=text size=92 value=")
Response.Write (rsWebsite("title"))
Response.Write ("></div><div><span>School</span><input name=school type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("school"))
Response.Write ("></div><div><span>What level is this course</span><input name=Course Level type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("level"))
Response.Write ("></div><div><span>How long does the course last?</span><input name=Course lasts for type=text size=75 alt=length|2 value=")
Response.Write (rsWebsite("lastsfor"))
Response.Write ("></div>")
'Move to the next record in the recordset
rsWebsite.MoveNext
Loop
%>
<%End If%>
<%End If%>
<%
rsWebsite.Close
dbGlobalWeb.Close
%>
Again, all seems to work just dandy EXCEPT FOR ONE THING ... where the course or school or whatever is more than one word (and most of them are) it doesn't display the rest of the words in the text box - only the first word shows up. If you look in the code of the document the words are there - they just don't show up in the text box! If you send the data through and have it land in a div or whatever (as plain text) it all shows up fine.
Can anybody PLEASE enlighten me as to why it's doing this and I'd be extreely grateful if you could tell me how to fix it!
Many, many thanks - I'm not an asp man (cobbled the above together from a couple of different scripts and got it working ... well, most of it anyway).