CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Gathering Info from 2 fields from 1 Drop Down List Box in ASP

Print topic Send  topic

Author Message
garycrunk

Posts: 23
Posted: 04/29/2008, 3:28 PM

Okay...

I have a database that I want to access in a List-Box and then once an item is selected, another field is automatically updated with the value from another field.

For example:
Products Table:
product_id
price

On the form, (Order Details) I will have the product_id list-box showing product name, when the user selects a product, the Product_Table.price is placed into the field for order_details_price.

IIs there an easy way to do that without a ton of programming?


_________________
Gary Crunk
Job Examiner
View profile  Send private message
marcwolf


Posts: 361
Posted: 04/29/2008, 6:41 PM

Yes.. But it will involve some programming.

here is how we did it.

We had a iframe on the page that was hidden.

Next we use the Javascript OnSelect (sorry - don't hve references handy but you will know what I mean) to call a javascript routine passing in the selected value

The Javascript sets the location on the iframe to a small ASP page that will perform the lookup using the passed selected value. For ease we usually have the main application connection string in an Application Session variable to ease setting up database connections.

The ASP page generates just a block of javascript that use the "windows.parent.element.value" to set the value into the field on the main page.
remember what you generate WILL need to inclise the <SCRIPT> and </SCRIPT> tages as well otherwise it will be seen just as pure HTML and not processed.

Although this seems to be a few tasks the principle is very simple and is akin to AJAX for communication with the server.

Debuggin is easy.. Increase the size of the iframe and make it visible. You can then see what is passed back. If nothing is passed back then the iframe is not getting it's Location property set correctly

Is you can see what is passes back as text then you have not got the <SCRIPT> tags form correctly.

You can also put in an 'alert' in what is passed back so you can see the value being sent.

If the alert shows the value but the page is not being updated the your windows.parent.element tag is not working.

Hope this all helps.

We have used this many time to pass back all sorts of information including ependant listboxes, long serverside calulations on a row by row basis etc.

If you are using a grid then you will need to rember that the design time field names will have the grid row appended onto the i.e.

designtime FIELD1 becomes FIELD1_1, FIELD1_2 etc for each row.
Use the element.name property and grab the characters after the last '_' and that will give you your row.. But this is getting into some of the more advances stuff.

let me know if you want some code snippets to helps.

Take care

Dave

_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.