473,395 Members | 1,639 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,395 software developers and data experts.

ASP/database problem

I hope I can make this clear:
I have an Access 2000 database that drives an ASP web site to track
sales leads.
There is a combo box , "units", that lists the inventory of models we
sell. Here's a code snippet

Fills the combo box:

<select name="units" id="units">
<%
While (NOT leads1.EOF)
%>
<option><%=(leads1.Fields.Item("units").Value)%> </option>
<%
leads1.MoveNext()
Wend
If (leads1.CursorType > 0) Then
leads1.MoveFirst
Else
leads1.Requery
End If

%>

This code works perfectly to fill the combobox with the model names
from the units table of the units db. Leads1 is the recordset that is
connected to the db

The 'units' table has three fields:

ID (autonumber - PK)
units - Text field
AnnValue - currency field

The form also has a readonly textbox, "AnnVal" to display the Annual
cost of the service contract for that unit.

Displays textbox:

<td valign="top"><input name="AnnVal" type="text" id="AnnVal"
size="15" readonly>
</td>
I want to populate that textbox with the data in the AnnValue field of
the units db. Based on the choice the user makes in the combobox, I
want the corresponding price to populate the read-only textbox.

I have seen several solutions that employ some Javascript with ASP to
get this to work but I have no idea how to implement these
suggestions. Being a real newbie, can someone offer some nicely
commented code to help me make this work the way I have described?

Thank you so much. You folks have always been so helpful!
Jul 22 '05 #1
3 1441
Doo-Dah Man wrote:
I hope I can make this clear:
I have an Access 2000 database that drives an ASP web site to track
sales leads.
There is a combo box , "units", that lists the inventory of models we
sell. Here's a code snippet

Fills the combo box:

<select name="units" id="units">
<%
While (NOT leads1.EOF)
%>
<option><%=(leads1.Fields.Item("units").Value)%> </option>
<%
leads1.MoveNext()
Wend
If (leads1.CursorType > 0) Then
leads1.MoveFirst
Else
leads1.Requery
<gasp> Ughhhhh!


This code works perfectly to fill the combobox with the model names
from the units table of the units db.
Maybe so. But .... ughhhh!
Leads1 is the recordset that is
connected to the db

The 'units' table has three fields:

ID (autonumber - PK)
units - Text field
AnnValue - currency field

The form also has a readonly textbox, "AnnVal" to display the Annual
cost of the service contract for that unit.

Displays textbox:

<td valign="top"><input name="AnnVal" type="text" id="AnnVal"
size="15" readonly>
</td>
I want to populate that textbox with the data in the AnnValue field of
the units db. Based on the choice the user makes in the combobox, I
want the corresponding price to populate the read-only textbox.

I have seen several solutions that employ some Javascript with ASP to
get this to work but I have no idea how to implement these
suggestions. Being a real newbie, can someone offer some nicely
commented code to help me make this work the way I have described?

Thank you so much. You folks have always been so helpful!


You really need to follow up in a client-side scripting newsgroup (such as
..scripting.jscript). This is very much off-topic in this newsgroup, once you
get part the issue of getting the lookup data into your clientside document.
The answer you need depends on how much cross-browser compatability you
need.

I would use an xml document to accomplish this. Instead of your slow
recordset loop and <gasp> requery, use GetRows to quickly pull your
recordset data into an array. Then close your recordset and connection, and
use the array to handle your data. (it's a simple for loop to loop through
the array to create your options for your dropdown box ... there is no such
thing as a "combo" in html).

You can also create an xml document by looping through the array. I have a
demo for doing this located here (since it uses an xml data island, this is
an IE-only demo - you can modify it with help from the client-side newsgroup
to make it more cross-browser compatible):

http://www.davidpenton.com/testsite/...ta.islands.asp
Once you have the data in a client-side xml document, you are in the realm
of client-side scripting (DHTML). Basically, you need to use the select
element's onchange event, creating a function that uses the select's value
to search through the cleint-side xml document (the data island can be
treated as an xml document) using the selectSingleNode method to find the
node containing the data you wat to put into the textbox.

I have another IE-only demo which can be found here - it's much more complex
than what you will need since it handles keystrokes instead of a selection
of a select element's option, but the basic ideas can be found in it:

http://www.thrasherwebdesign.com/dow...1/listdemo.zip
(read the "Dynamic Listbox" description on this page:
http://www.thrasherwebdesign.com/ind...asp&c=&a=clear
The DHTML documentation can be found here:
http://msdn.microsoft.com/workshop/a...iews_entry.asp
and here:
http://msdn.microsoft.com/workshop/a...ence_entry.asp
The XML documentation can be found here:
http://msdn.microsoft.com/library/en...MLOverview.asp
There are other solutions to be found at www.aspfaq.com.

This is truly a FAQ - you could have avoided this post by using Google.
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2
I spent a lot of time searching Google and never found what I was
looking for. Thanks for responding. Not sure if I completely
understand what you're saying here, but I will read through all the
links.


On Tue, 29 Mar 2005 06:56:56 -0500, "Bob Barrows [MVP]"
<re******@NOyahoo.SPAMcom> stood up, looked around, realized where he
was, and wrote:
Doo-Dah Man wrote:
I hope I can make this clear:
I have an Access 2000 database that drives an ASP web site to track
sales leads.
There is a combo box , "units", that lists the inventory of models we
sell. Here's a code snippet

Fills the combo box:

<select name="units" id="units">
<%
While (NOT leads1.EOF)
%>
<option><%=(leads1.Fields.Item("units").Value)%> </option>
<%
leads1.MoveNext()
Wend
If (leads1.CursorType > 0) Then
leads1.MoveFirst
Else
leads1.Requery


<gasp> Ughhhhh!


This code works perfectly to fill the combobox with the model names
from the units table of the units db.


Maybe so. But .... ughhhh!
Leads1 is the recordset that is
connected to the db

The 'units' table has three fields:

ID (autonumber - PK)
units - Text field
AnnValue - currency field

The form also has a readonly textbox, "AnnVal" to display the Annual
cost of the service contract for that unit.

Displays textbox:

<td valign="top"><input name="AnnVal" type="text" id="AnnVal"
size="15" readonly>
</td>
I want to populate that textbox with the data in the AnnValue field of
the units db. Based on the choice the user makes in the combobox, I
want the corresponding price to populate the read-only textbox.

I have seen several solutions that employ some Javascript with ASP to
get this to work but I have no idea how to implement these
suggestions. Being a real newbie, can someone offer some nicely
commented code to help me make this work the way I have described?

Thank you so much. You folks have always been so helpful!


You really need to follow up in a client-side scripting newsgroup (such as
.scripting.jscript). This is very much off-topic in this newsgroup, once you
get part the issue of getting the lookup data into your clientside document.
The answer you need depends on how much cross-browser compatability you
need.

I would use an xml document to accomplish this. Instead of your slow
recordset loop and <gasp> requery, use GetRows to quickly pull your
recordset data into an array. Then close your recordset and connection, and
use the array to handle your data. (it's a simple for loop to loop through
the array to create your options for your dropdown box ... there is no such
thing as a "combo" in html).

You can also create an xml document by looping through the array. I have a
demo for doing this located here (since it uses an xml data island, this is
an IE-only demo - you can modify it with help from the client-side newsgroup
to make it more cross-browser compatible):

http://www.davidpenton.com/testsite/...ta.islands.asp
Once you have the data in a client-side xml document, you are in the realm
of client-side scripting (DHTML). Basically, you need to use the select
element's onchange event, creating a function that uses the select's value
to search through the cleint-side xml document (the data island can be
treated as an xml document) using the selectSingleNode method to find the
node containing the data you wat to put into the textbox.

I have another IE-only demo which can be found here - it's much more complex
than what you will need since it handles keystrokes instead of a selection
of a select element's option, but the basic ideas can be found in it:

http://www.thrasherwebdesign.com/dow...1/listdemo.zip
(read the "Dynamic Listbox" description on this page:
http://www.thrasherwebdesign.com/ind...asp&c=&a=clear
The DHTML documentation can be found here:
http://msdn.microsoft.com/workshop/a...iews_entry.asp
and here:
http://msdn.microsoft.com/workshop/a...ence_entry.asp
The XML documentation can be found here:
http://msdn.microsoft.com/library/en...MLOverview.asp
There are other solutions to be found at www.aspfaq.com.

This is truly a FAQ - you could have avoided this post by using Google.
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Jul 22 '05 #3
"Doo-Dah Man" <ye**@right.com> wrote in message
news:0u********************************@4ax.com...
I hope I can make this clear:
I have an Access 2000 database that drives an ASP web site to track
sales leads.
There is a combo box , "units", that lists the inventory of models we
sell. Here's a code snippet

Fills the combo box:

<select name="units" id="units">
<%
While (NOT leads1.EOF)
%>
<option><%=(leads1.Fields.Item("units").Value)%> </option>
<%
leads1.MoveNext()
Wend
If (leads1.CursorType > 0) Then
leads1.MoveFirst
Else
leads1.Requery
End If

%>

This code works perfectly to fill the combobox with the model names
from the units table of the units db. Leads1 is the recordset that is
connected to the db

The 'units' table has three fields:

ID (autonumber - PK)
units - Text field
AnnValue - currency field

The form also has a readonly textbox, "AnnVal" to display the Annual
cost of the service contract for that unit.

Displays textbox:

<td valign="top"><input name="AnnVal" type="text" id="AnnVal"
size="15" readonly>
</td>
I want to populate that textbox with the data in the AnnValue field of
the units db. Based on the choice the user makes in the combobox, I
want the corresponding price to populate the read-only textbox.

I have seen several solutions that employ some Javascript with ASP to
get this to work but I have no idea how to implement these
suggestions. Being a real newbie, can someone offer some nicely
commented code to help me make this work the way I have described?

Thank you so much. You folks have always been so helpful!


Perhaps this is what you want:
<input name="AnnVal" type="text" id="AnnVal" size="15" readonly>

<select name="units" id="units"

onchange="document.forms[0].AnnVal.value=document.forms[0].options[document.
forms[0].selectedIndex].value">
<% While Not leads1.EOF %>
<option
value="<%=leads1("AnnValue").Value%>"><%=leads1("u nits").Value%></option>
<% leads1.MoveNext()
Wend
If (leads1.CursorType > 0) Then
leads1.MoveFirst
Else
leads1.Requery
End If
%>

Jul 22 '05 #4

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

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
7
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
2
by: Robert McGregor | last post by:
Hi all, I've got a Front End / Back End database that was working just fine. One day i opened the FE to find that if I tried to open one of the linked tables from the database window, nothing...
19
by: adirat | last post by:
I have read a lot on this subject on newsgroups and other access related websites on data corruption, but since we are still not able to isolate the problem – I am posting this detailed explanation...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
6
by: xeqister | last post by:
Greetings, We are having a situation here whereby one of our staff created a very huge 32K buffer pool in a production database and caused the database to go down. When we try to reconnect to the...
12
by: Steve | last post by:
I have a database that raises an error when you try to open it and it doesn't open. Trying to open the database with the OpenDatabase method raises the same error. Trying to import any objects...
4
by: raidvvan | last post by:
Hi there, We have been looking for some time now for a database system that can fit a large distributed computing project, but we haven't been able to find one. I was hoping that someone can...
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: 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...
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
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...
0
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...

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.