472,353 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Which Is the Best Approach?

A Form has a select list which is populated from a MS-Access database
table. The DB table from where the select list is populated has 2
columns - CountryID & CountryName. When the Form is posted, the option
selected in the select list is inserted in another DB table wherein
the column in which the value of the selected option will be populated
accepts only integers. Actually there are 7-8 select lists & the
values of all the selected options in all the select lists are
populated in another DB table. The DB tables also have Primary Keys,
Foreign Keys, Constraints etc. I am using only a single select list
here to maintain brevity.

Now I have set the value of each option in the select list to the
CountryID column & not the CountryName column which means that the
HTML source of the select list would look something like this:

<select name="selCountry">
<option value="1">Afghanistan</option>
<option value="2">Belgium</option>
<option value="3">Canada</option>
<option value="4">Denmark</option>
<option value="5">Egypt</option>
<option value="6">Finland</option>
<option value="7">Ghana</option>
<option value="8">Hungary</option>
<option value="9">India</option>
.........
</select>

Assume that I have selected Canada from the above select list. Now
when the Form that houses the select list is posted,
Request.Form("selCountry") in the action page will be 3. The action
page also needs to send a e-mail to the webmaster with the country
name the user has selected. Since I have selected Canada, the
webmaster will get a mail which will say that "the user has selected
Canada" but since Request.Form("selCountry")=3, the webmaster will get
a mail saying "the user has selected 3" but this is not what the
webmaster wants to see when he gets the mail. He wants the mail to say
"the user has selected Canada" & not "the user has selected 3".

There are quite a few ways to overcome this issue, three of which I am
talking about.

1. Add a hidden field in the Form whose name is, say, "hdnCountry" &
change it's value depending upon the option selected by a user in the
select list with JavaScript using the onChange event function of the
select list. So if a user first selects, say, Egypt in the select
list, the hidden field value will be Egypt. Next he selects Canada;
the hidden field value will change to Canada (note that only 1 option
can be selected in the select list). When the Form posts, use
Request.Form("hdnCountry") in the e-mailing code (instead of
Request.Form("selCountry")) which will give the name of the country.
Since there's only 1 select list, the increase in the volume of data
sent by the browser to the server will be small since along with the
value of the select list, the browser also has to send the value of
the hidden field to the server but if there are 7-8 select lists, then
the volume of data the browser sends to the server will increase
drastically.

2. No hidden field here; only the select list is present.
Request.Form("selCountry") will be 3 (assuming Canada is selected in
the select list). Next using Request.Form("selCountry"), get the
corresponding country name from the database which means an additional
frontend-backend communication which can be avoided if a hidden field
is placed in the Form as mentioned above.

3. No hidden field here as well; only the select list but the value of
the options in the select list is changed so that it includes the
CountryID as well as the CountryName with the two being delimited by a
comma (or something else) which means that the HTML source of the
select list would look something like this:

<select name="selCountry">
<option value="1, Afghanistan">Afghanistan</option>
<option value="2, Belgium">Belgium</option>
<option value="3, Canada">Canada</option>
<option value="4, Denmark">Denmark</option>
<option value="5, Egypt">Egypt</option>
<option value="6, Finland">Finland</option>
<option value="7, Ghana">Ghana</option>
<option value="8, Hungary">Hungary</option>
<option value="9, India">India</option>
.........
</select>

Assuming that Canada is selected in the select list, when the Form
posts, the value of Request.Form("selCountry") will be *3, Canada* (of
course, without the *s). Using various VBScript string functions like
Split, separate Request.Form("selCountry") into 2 halves so that the
1st half retrieves the CountryID & the second half retrieves the
CountryName. So while inserting the selected option in the DB table,
populate the DB table with the first half & send the mail using the
second half of Request.Form("selCountry"). But this method will
consume additional server resources since the server has to do the
additional tasks of using the string functions & dividing
Request.Form("selCountry") into 2 parts.

All the above 3 methods I have mentioned have their pros & cons. So
which one will be the best way to approach in such a situation?

Again please keep in mind that I have used only 1 select list in this
example to maintain brevity but in reality, there are around 7-8
(maybe even more) select lists.

May 3 '07 #1
2 2120
<rn**@rediffmail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
A Form has a select list which is populated from a MS-Access database
table. The DB table from where the select list is populated has 2
columns - CountryID & CountryName. When the Form is posted, the option
selected in the select list is inserted in another DB table wherein
the column in which the value of the selected option will be populated
accepts only integers.
[snip]
Request.Form("selCountry") into 2 parts.
CountryID = Split(Request.Form("selCountry"),",")(0)
All the above 3 methods I have mentioned have their pros & cons. So
which one will be the best way to approach in such a situation?
[snip]

I would not recommend assigning a number to a country.
Currently yours are in alphabetical and numerical sequence;
what happens when a new country is added?

However, pre-assigned three-digit numbers already exist:
http://en.wikipedia.org/wiki/ISO_3166-1_numeric
<select name="selCountry">
<option value="004">Afghanistan</option>
<option value="056">Belgium</option>
<option value="124">Canada</option>
<option value="208">Denmark</option>
<option value="818">Egypt</option>
<option value="246">Finland</option>
<option value="188">Ghana</option>
<option value="348">Hungary</option>
<option value="356">India</option>
.........
</select>

Build an additional table with these codes and names.
May 4 '07 #2
On May 4, 5:39 am, "McKirahan" <N...@McKirahan.comwrote:
<r...@rediffmail.comwrote in message

news:11**********************@h2g2000hsg.googlegro ups.com...
A Form has a select list which is populated from a MS-Access database
table. The DB table from where the select list is populated has 2
columns - CountryID & CountryName. When the Form is posted, the option
selected in the select list is inserted in another DB table wherein
the column in which the value of the selected option will be populated
accepts only integers.

[snip]
Request.Form("selCountry") into 2 parts.

CountryID = Split(Request.Form("selCountry"),",")(0)
All the above 3 methods I have mentioned have their pros & cons. So
which one will be the best way to approach in such a situation?

[snip]

I would not recommend assigning a number to a country.
Currently yours are in alphabetical and numerical sequence;
what happens when a new country is added?

However, pre-assigned three-digit numbers already exist:
http://en.wikipedia.org/wiki/ISO_3166-1_numeric

<select name="selCountry">
<option value="004">Afghanistan</option>
<option value="056">Belgium</option>
<option value="124">Canada</option>
<option value="208">Denmark</option>
<option value="818">Egypt</option>
<option value="246">Finland</option>
<option value="188">Ghana</option>
<option value="348">Hungary</option>
<option value="356">India</option>
........
</select>

Build an additional table with these codes and names.
>Currently yours are in alphabetical and numerical sequence
That's just an example but in reality, it may or may not be in
alphabetical & numerical sequence. I want the countries to be listed
alphabetically. So the SQL query will use the ORDER BY clause
something like this:

SELECT * FROM Countries ORDER BY CountryName
>what happens when a new country is added?
Let new countries be added or existing countries be deleted, what
difference does it make?
>I would not recommend assigning a number to a country.
The Country codes I have assigned is to link/JOIN the Countries table
with some other table. They are for the programmers use; ultimately
users won't be seeing or using those codes in anyway. For e.g. after
adding some items to his cart, a user is told to enter his billing
address. He selects, say, Canada as his country. After confirming,
Canada's country code, which is 3 in this case will be inserted in
another DB table named, say, Details, which holds all the other
personal details of users (like first & last name, e-mail, phone no.
etc.).

Later a user wants to view the order details wherein country is one of
the details. To do so, the SQL query will be something like this:

SELECT D.CountryID, C.CountryName,....FROM Details AS D INNER JOIN
Countries AS C ON C.CountryID=D.CountryID WHERE..........

Then <%= objRS("CountryName") %will display him his country (objRS
is the recordset).

May 4 '07 #3

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

Similar topics

17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: ...
1
by: milesm | last post by:
I've spent the last 3 hours reading various MSDN articles, other site articles and news group postings and was wondering what the best approach to...
10
by: Mike Logan | last post by:
I am using the "contract first" design methodology. Contract First is design the WSDL first then design the server and client. However I must...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing...
4
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to...
6
by: bill | last post by:
I am about to start on a module that will accept a location from a user, use Google geolocation services to get the lat/lon and then compute the...
20
by: Neo Geshel | last post by:
I have been looking into Javascript libraries for the last week or two here, and there are certainly a lot of options out there. ...
3
by: =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post by:
Hi, I'm doing an application using C# and I have this question: I have a method called sqlQueryBD which receives a string sql query and executes...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.