
select values--posting to mdb (beginner, asp)
I've tried, lord knows, I've tried... if anyone could show me what I'm
doing wrong with this script it just might save the rest of my hair.
The idea is embarrassingly simple, much like my knowledge of ASP: to
ask the user to choose an option from the select box, and store that
option, along with the date, in an access database. The ODBC connection
has been verified: the script works when I put constants in the
VALUES(), but I can't for the life of me get the script to read the
form. As you can see, I'm trying to make it so that the user doesn't
have to click a submit button.. after they make the choice, they just
see the window disappear, and return to the parent document.
Oh yeah, since the successful testruns with the constant values, I have
made the following changes(reasons):
Made the script into a SUB and called it with the onChange handler
(previously had onChange=submit() but without SUB-bing the script, it
would automatically run on loading and insert info into the .mdb whether
the form was completed or not.
..er, well that's the only change I've made. Currently when I load the
page, when I change the selected value in the form, I get an "Object
Expected" javascript error (?) on the line containing the <select>.. I'm
nearly at my wit's end.
I hope I explained this clearly enough.. if you have the answer, please
explain it to me like I'm a 6-year-old.. : ) don't be afraid of
insulting my intelligence.
<!-begin dysfunctional script -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<%
Dim conn
Dim SourceAnswer
Dim SqlStr
sub ReadMe()
SourceAnswer =
request.form("theform.source[theform.source.selectedindex].value")
SqlStr = "INSERT INTO results (Answer,AnswerDate) Values('" &
SourceAnswer & "','01/01/99')"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "FILEDSN=SourcePollResults.dsn"
conn.Execute SqlStr
Set conn = Nothing
end sub
%>
<HTML>
<HEAD>
<TITLE>Lens Express wants to know:</TITLE>
</HEAD>
<BODY BACKGROUND='images/back.jpg'>
<center>
<FORM method="post" action="sourcepoll.asp" name="theform">
<table width="100%" height="100%">
<tr><td align="center" valign="middle">
<select name="source" size="1" onChange="ReadMe(), window.close(self)">
<option selected value="no answer">How did you hear about us?</option>
<option value="Search Engine">Search Engine</option>
<option value="Banner Ad">Banner Ad</option>
<option value="tv">Television Ad</option>
<option value="print">Print Ad</option>
<option value="brochure">Brochure</option>
<option value="refer">Referral</option>
</select></td>
</tr>
</table>
</FORM>
</center>
</BODY>
</HTML>