473,785 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">0 0:00</option>
<option value="00:30">0 0:30</option>
<option value="01:00">0 1:00</option>
<option value="01:30">0 1:30</option>
<option value="02:00">0 2:00</option>
<option value="02:30">0 2: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("s ubject")
strDate = request.Form("t heDate")
strTime = request.Form("t ime")
strBody = request.Form("b ody")
strName = request.Form("n ame")
strTel = request.Form("t el")
strEmail = request.Form("e mail")

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&"' ,'"&strBody&"', '"&strName&"',' "
&strTel&"','"&s trEmail&"')"

set MyConn = oConn.Execute(s ql)
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 3449
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(s ql)
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&"','"&s trSubject&"','"

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*****@somewh ere.com> wrote in message
news:bu******** **@sparta.btint ernet.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">0 0:00</option>
<option value="00:30">0 0:30</option>
<option value="01:00">0 1:00</option>
<option value="01:30">0 1:30</option>
<option value="02:00">0 2:00</option>
<option value="02:30">0 2: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("s ubject")
strDate = request.Form("t heDate")
strTime = request.Form("t ime")
strBody = request.Form("b ody")
strName = request.Form("n ame")
strTel = request.Form("t el")
strEmail = request.Form("e mail")

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&"' ,'"&strBody&"', '"&strName&"',' " &strTel&"','"&s trEmail&"')"

set MyConn = oConn.Execute(s ql)
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
2418
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 method=post > <select name= "name">
9
6049
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 value="1">test</option> </select>
1
12183
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
6440
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 between "display='none'" and "display=''". However the problem is that - in Internet Explorer 6 the dropdown (<select>...) always hides the menu
2
1734
by: abs | last post by:
Hello everybody. A piece of html code: <form ... > <select ....> <option .... <option .... </select> <select ....>
6
2408
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 say I have values selected for all three pull down menus. When I change the first "top-level" menu I want to reset both the second and third menus to the "default" state.
2
1662
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 table are as follows:
1
8854
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 to allow editing of the data already in the table. I can read the data out of the database without trouble, however I am having trouble figuring out a way to have the appropriate option in the <Select> fields chosen to reflect the data already in...
1
1635
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 change this value so that IE would show only 10 elements from the select field at once? Thanks for Your reply, Ximian
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.