473,387 Members | 1,365 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,387 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 2200
<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: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
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 my situation would be since I'm unable to come up...
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 design my XSD/XML Schema before anything. I am...
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 that resulted in data in temp tables, I would have...
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 do is include some code that tests if a user is...
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 distance from the site visitor to about 100 kennels...
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. http://www.prototypejs.org/ http://mootools.net/...
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 it against a database. I also have a class called...
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 the following C++ code. The first routine runs in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.