ASP not recognizing dynamic values

Posted on 2006-04-18
Last Modified: 2010-05-19
Okay, I have 2 select boxes, one is populated by the other thru a commonly used javascript. That works without any problems. Now I need to insert the values from the newly populated select box into a sql tbl. this is where we run into a problem. It seems that ASP & SQL will not recognize the values from the dynamicly generated select list. Here is the code. There is a hidden field to trigger the if statement. The kicker is if I just use the single drop down (list1) to insert diredctly from there is no problems, so I know that it's a recognition problem.

<!--Insert Statement//-->
if Request.Form("action") = "pick" then

if(Request.Form("grpName") <> "") then courseGrpInsert__MMColParam1 = Request.Form("grpName")
if(Request.Form("grpIdentNumber") <> "") then grpIdentNumber = Request.Form("grpIdentNumber")

Dim arrCourse
arrCourse = Request.Form("list2")
arrCourse = Split(arrCourse,",")

For i = 0 to uBound(arrCourse)
'SQL Insert Command here

set courseGrpInsert = Server.CreateObject("ADODB.Command")
courseGrpInsert.ActiveConnection = MM_Employees_STRING
courseGrpInsert.CommandText = "INSERT INTO  trainingGroups (grpIdentNumber,grpName,course_id )  VALUES (" + "'" + trim(grpIdentNumber) + "'" + "," + "'" + trim(courseGrpInsert__MMColParam1) + "'" + "," + trim(arrCourse(i)) + ")"
courseGrpInsert.CommandType = 1
courseGrpInsert.CommandTimeout = 0
courseGrpInsert.Prepared = true


end if

<!--End Insert//-->

<!--Code for the two select boxes//-->

            <td align="center" valign="middle">
                  <select class = "db" multiple size="10" name="list2" style="width:275">
            <td align="center" valign="middle">
                  <input type="button" value="Add"
                   onclick="moveOptions(this.form.list1, this.form.list2);" />
                  <input type="button" value="Delete"
                   onclick="moveOptions(this.form.list2, this.form.list1);" />
            <td align="center" valign="middle">
            Course List
            <td align="center" valign="middle">
                  <select class = "db" multiple size="10" name="list1" style="width:275">

                        While (NOT courseList.EOF)
                    <option value="<%=(courseList.Fields.Item("course_id").Value)%>"><%=(courseList.Fields.Item("Course").Value)%></option>
                        If (courseList.CursorType > 0) Then
                        End If
<!--end select boxes//-->
Question by:NMCoderMike
    LVL 17

    Expert Comment

    which is database you use, and how does this page work, It raise excception?
    LVL 6

    Accepted Solution


    you can collect the list item before user submit the form :

    1.add a hidden field name list3
    2.onsubmit action(javascript):
    list3.value = '';
      list3.value = list3.value + list1.option[i].value + ","  

    3.change asp to
    arrCourse = Request.Form("list3")
    arrCourse = Split(arrCourse,",")


    LVL 75

    Expert Comment

    by:Anthony Perkins
    Please delete the following duplicate question, before someone contributes as it violates the 500 point maximum.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Android App Development

    This course will involve creating widgets, customize list view, grid view, spinners, etc. Creating applications using audio, video, and SQLite database. Ending with publication on Google Play.

    Shoutout to Emily Plummer ( for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now