Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: 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!

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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.

  3. #3
    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 10:54.

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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...

  5. #5
    Join Date
    Sep 2003
    Posts
    10

    Talking

    Thanks, it all works now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •