If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Adding values from an ASP combobox into a database table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-18-04, 12:48
Si_K Si_K is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Adding values from an ASP combobox into a database table

Hi,

I am designing a system for my company that logs training programmes they have been on. I have a table which holds various fields (the 2 of which im interested in are course_id and coursename). I have an ASP page which contains an evaluation form that staff can use to put their views on each training course forward. In this form there is a combo box which holds the course_id and the coursename of every course run. The code for my combobox is as follows:

Code:
<select name=coursecombobox>
<%
Do While Not display1.EOF
response.write "<option value =  " & chr(34) & display1("course_id") & chr(34) & display1("coursename") & chr(34) & "  >"
response.write display1("course_id") & "     " & display1("coursename") & "</option>
display1.MoveNext 
loop 
%>
</select>

What I need to do is when users click submit, the course_id goes to the course_id field in my evaluation table, and the coursename value goes to the coursename field in my evaluation table. This is not happening at the moment. The code I am using to send all my data to the evaluation table is as follows:

Code:
evaluation.AddNew
		evaluation("user_id") = session("UID")
		evaluation("course_id") = Request.Form("courselistbox("display1("course_id")")")
		evaluation("coursename") = Request.Form("courselistbox("display1("coursename")")")
		evaluation("session_relevance_rating") = Request.Form("qSessionRelevanceListbox")
		evaluation("session_relevance_comments") = Request.Form("qSessionRelevanceComments")
		evaluation("tutor_balance_input_rating") = Request.Form("qTutorBalanceListbox")
		evaluation("tutor_balance_input_comments") = Request.Form("qTutorBalanceComments")
		evaluation("course_interesting_rating") = Request.Form("qCourseInterestingListbox")
		evaluation("course_interesting_comments") = Request.Form("qCourseInterestingComments")
		evaluation("course_aims_rating") = Request.Form("qCourseAimsListbox")
		evaluation("course_aims_comments") = Request.Form("qCourseAimsComments")
		evaluation("effective_trainers_rating") = Request.Form("qEffectiveTrainersListbox")
		evaluation("effective_trainers_comments") = Request.Form("qEffectiveTrainersComments")
		evaluation("overall_organisation_rating") = Request.Form("qOverallOrganisationListbox")
		evaluation("overall_organisation_comments") = Request.Form("qOverallOrganisationComments")
		evaluation("venue_facilities_rating") = Request.Form("qVenueFacilitiesListbox")
		evaluation("venue_facilities_comments") = Request.Form("qVenueFacilitiesComments")
		evaluation("aspects_most_useful") = Request.Form("qAspectsMostUsefulComments")
		evaluation("aspects_most_useful_reasons") = Request.Form("qAspectsMostUsefulReasonsComments")
		evaluation("aspects_least_useful") = Request.Form("qAspectsLeastUsefulComments")
		evaluation("aspects_least_useful_reasons") = Request.Form("qAspectsLeastUsefulReasonsComments")
		evaluation("training_session_improve") = Request.Form("qTrainingSessionImproveComments")
		evaluation("day_to_day_incorporation") = Request.Form("qDayToDayIncorporationComments")
		evaluation("comments") = Request.Form("qComments")
		evaluation("hear_about_course") = Request.Form("qHearAboutCourseComments")
		evaluation("additional_training") = Request.Form("allcourselistbox")
		evaluation("other_training") = Request.Form("qOtherTrainingComments")
		evaluation("posteddate") = Date
		evaluation.Update
Sorry if im being a bit vague. Can anyone give me any pointers as to where im going wrong? The error message I get is as follows:

Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/devdata/sendevaluationform.asp, line 22, column 55

which applies to the following line in the above code:

Code:
evaluation("course_id") = Request.Form("courselistbox("display1("course_id")")")
Thanks!
Reply With Quote
  #2 (permalink)  
Old 03-18-04, 15:30
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
replace this
Code:
evaluation("course_id") = Request.Form("courselistbox("display1("course_id")")")
		evaluation("coursename") = Request.Form("courselistbox("display1("coursename")")")
with this
Code:
strCourseCombo = Request.Form("coursecombobox")
arrCourse = split(strCourceCombo," ")
myCourseId = arrCourse(0)
myCourseName = arrCourse(1)
evaluation("course_id") = myCourseId
evaluation("coursename") = myCourseName
I might have to syntax of the split function wrong but it should be close enough for you to look at the help and correct it.
Reply With Quote
  #3 (permalink)  
Old 03-23-04, 06:55
Si_K Si_K is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Cheers for that I am getting the following error though:

Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 1]'

I have tried declaring the array

Dim arrCourse(2)

but this then creates a type mismatch with the following line:

arrCourse = split(strCourseCombo," ")

Last edited by Si_K; 03-23-04 at 09:54.
Reply With Quote
  #4 (permalink)  
Old 03-23-04, 18:48
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Opps,.. sorry about that... I missed this little beauty....

Replace
Code:
response.write "<option value =  " & chr(34) & display1("course_id") & chr(34) & display1("coursename") & chr(34) & "  >"
with
Code:
response.write "<option value =  " & chr(34) & display1("course_id") & " " & display1("coursename") & chr(34) & "  >"
Chr(34) is a ' or " yes?? I can't remember and don't want to look it up...
Reply With Quote
  #5 (permalink)  
Old 03-30-04, 05:33
Simon K Simon K is offline
Registered User
 
Join Date: Sep 2003
Posts: 10
Talking

Thanks, it all works now
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On