473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

array query with multiple <SELECT> form field

I have a SELECT statement which holds a list of times (for adding
appointments to a database):

e.g.

<select name="time" id="time" size="3" multiple>
<option value="00:00">00:00</option>
<option value="00:30">00:30</option>
<option value="01:00">01:00</option>
<option value="01:30">01:30</option>
<option value="02:00">02:00</option>
<option value="02:30">02:30</option>
</select>

on the process page, I want to loop through the values of the "time" select
field, and enter them into a database.

I have tried this:

strSubject = request.Form("subject")
strDate = request.Form("theDate")
strTime = request.Form("time")
strBody = request.Form("body")
strName = request.Form("name")
strTel = request.Form("tel")
strEmail = request.Form("email")

myArray = Split(Request("time"),",")

For iy = 0 To UBound(myArray)
sql = "INSERT INTO appointments (the_Date, the_time, fldSub, fldBod,
fldName, fldTel, fldEmail) "
sql = sql & " VALUES
('"&strDate&"','"&strTime&"','"&strSubject&"','"&s trBody&"','"&strName&"','"
&strTel&"','"&strEmail&"')"

set MyConn = oConn.Execute(sql)
Set MyConn = Nothing
Next

but it only inserts into the database the value of the first "time" record
(e.g. if I selected 00:00, 00:30, 02:30 it inserts "00:00" each of the three
times through the loop.

The output of the "time" field is:

00:00, 00:30, 02:30

so I thought this line:

myArray = Split(Request("time"),",")

would split the "time" field into 3 chunks, and each time through the loop I
was expecting it to take the next value.

Am I missing something obvious?

Thanks

Jim

Jul 19 '05 #1
1 3428
You're inserting strTime instead of myArray(iy).

Also, you should split with ", " instead of "," since there's that space in
between each time value.

Also, instead of
Set MyConn = oConn.Execute(sql)
just use:
oConn.Execute sql

One other suggestion I have is to get in the habit of using spaces when
concatenating strings. Like, instead of:

&strDate&"','"&strTime&"','"&strSubject&"','"

do:

& strDate & "','" & strTime & "','" & strSubject & "','" ...

In addition to making your code more readable, it'll avoid confusion when
you're using code like so:

Dim h1
h1 = "15 feet"
Response.Write "Joe jumped "&h1

Ray at home

"Burton Figg" <so*****@somewhere.com> wrote in message
news:bu**********@sparta.btinternet.com...
I have a SELECT statement which holds a list of times (for adding
appointments to a database):

e.g.

<select name="time" id="time" size="3" multiple>
<option value="00:00">00:00</option>
<option value="00:30">00:30</option>
<option value="01:00">01:00</option>
<option value="01:30">01:30</option>
<option value="02:00">02:00</option>
<option value="02:30">02:30</option>
</select>

on the process page, I want to loop through the values of the "time" select field, and enter them into a database.

I have tried this:

strSubject = request.Form("subject")
strDate = request.Form("theDate")
strTime = request.Form("time")
strBody = request.Form("body")
strName = request.Form("name")
strTel = request.Form("tel")
strEmail = request.Form("email")

myArray = Split(Request("time"),",")

For iy = 0 To UBound(myArray)
sql = "INSERT INTO appointments (the_Date, the_time, fldSub, fldBod,
fldName, fldTel, fldEmail) "
sql = sql & " VALUES
('"&strDate&"','"&strTime&"','"&strSubject&"','"&s trBody&"','"&strName&"','" &strTel&"','"&strEmail&"')"

set MyConn = oConn.Execute(sql)
Set MyConn = Nothing
Next

but it only inserts into the database the value of the first "time" record
(e.g. if I selected 00:00, 00:30, 02:30 it inserts "00:00" each of the three times through the loop.

The output of the "time" field is:

00:00, 00:30, 02:30

so I thought this line:

myArray = Split(Request("time"),",")

would split the "time" field into 3 chunks, and each time through the loop I was expecting it to take the next value.

Am I missing something obvious?

Thanks

Jim

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php...
9
by: aragon | last post by:
Hi all, is it legal to use a fully-numeric string as "name" attribute for the <select> tag in the XHTML standard? E.g.: <form action="action.php" method="get"> <select name="12345"> <option...
1
by: Matthias Wege | last post by:
hello, is there any chance to shape borders of a <select>-field? i tried select { background-color:#eee; border:1px solid red; }
2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
2
by: abs | last post by:
Hello everybody. A piece of html code: <form ... > <select ....> <option .... <option .... </select> <select ....>
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
2
by: Astra | last post by:
Hi All Wondered if you could help me with the below query. I have 1 simple table called STOCKCATS that consists of 2 fields. These fields are called CATID and LEVEL. The contents of this...
1
by: ghadley_00 | last post by:
Hi, I have a php form that encodes the responses to various <Select> field drop down menus as numbers (e.g. 0 to 50), and then posts the data to a MySQL table. I am trying to implement a form...
1
by: ximian | last post by:
(IE6) When <select> tag contains many elements (eg. 50) it cannot display them at once. IE6 displays 30 elements at most and shows the vertical scrollbar. My question is: is it possible to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.