?
Solved

ASP not recognizing dynamic values

Posted on 2006-04-18
3
Medium Priority
?
305 Views
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
courseGrpInsert.Execute()


Next

end if

<!--End Insert//-->

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

      <tr>
            <td align="center" valign="middle">
                  <select class = "db" multiple size="10" name="list2" style="width:275">
                  </select>
            </td>
      </tr>
      <tr>
            <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>
      </tr>
      <tr>
            <td align="center" valign="middle">
            Course List
            </td>
      </tr>
      <tr>
            <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>
                    <%
                          courseList.MoveNext()
                        Wend
                        If (courseList.CursorType > 0) Then
                          courseList.MoveFirst
                        Else
                          courseList.Requery
                        End If
                        %>
                  </select>
            </td>
      </tr>
<!--end select boxes//-->
0
Comment
Question by:NMCoderMike
3 Comments
 
LVL 17

Expert Comment

by:HuyBD
ID: 16495087
which is database you use, and how does this page work, It raise excception?
0
 
LVL 6

Accepted Solution

by:
darkeryu earned 2000 total points
ID: 16495537
Hi:

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

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

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

thanks

 
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16513452
Please delete the following duplicate question, before someone contributes as it violates the 500 point maximum.
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21820297.html

Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

755 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