Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2006, 05:10 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic List Content

HELP....
I am having two list boxes in the ASP page which displays data from the database filed.
One is for selecting the category (Default-ALL). And another one for listing items in the selected category.
By default I have listed all the items in the itemlist box. If the user selects specific category it should display the item list for the specific category. If possible give some idea.

Thanks in advance.
 
Old October 19th, 2006, 07:30 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Umm do Request.Form("element") to get the value?

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 23rd, 2006, 02:23 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<FORM Method="POST" Action="showissue.asp">
<P>Category
<INPUT id=radio1 type=radio name=cat value="CA" checked onClick="showCat()">All
<INPUT type=radio name=cat value="CS" onClick="showCat()">Specific<Br>
Select Category
<SELECT id=catlist style="WIDTH: 164px" name=catlist disabled>
<OPTION selected>Stationery</OPTION>
<OPTION>Sanitary</OPTION>
<OPTION>Perishable</OPTION>
</SELECT></P>
<P>Item
<INPUT type=radio name="item" value="IA" CHECKED onClick="showItem()">All
<INPUT type=radio name="item" value="IS" onClick="showItem()">Specific<Br>
Select Item
<%
Set objCon=Server.CreateObject("ADODB.Connection")
objcon.open "stores"

Set rsItem=Server.CreateObject("ADODB.Recordset")
rsItem.open "Select Icode,Name From Item Order By Name",objCon
%>
<SELECT style="WIDTH: 281px" name="itemlist" SIZE="1" disabled>
<%
Do While Not rsItem.EOF
Response.Write "<OPTION VALUE="&rsItem("Icode")&">"&rsItem("Name")&"</OPTION>"
rsItem.MoveNext
Loop

rsItem.Close
Set rsItem=nothing
%>
</SELECT></P>
</FORM>
 
Old October 24th, 2006, 10:29 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the typical example of where AJAX is useful.

If I understand your requirement, what you want to do is populate the Item List with a different set of values based on what is selected in the category list.

There are at least three ways to do this:
1 - Make a post of the page - this requires a "full" round-trip to the server and is the worst solution of the three I cover here.
2 - Hold a client side copy of the entire list in an array in Javascript or in some XML block in the html, and use that array to repopulate the Item List dynamically. This is not too bad as long as the item list is more or less short.
3 - Use AJAX to make a call to get the filtered list you need and dynamically reset the Item List with it.

Solutions 2 and 3 require manipulating the DOM of your HTML document dynamically using Javascript (or any other supported scripting language... but of course, Javascript is the only realistic choice).

There are other solutions such as data islands, and I am sure there are soluctions I don't know about or have never considered.

AJAX is very popular right now, but it has actually been around in its current form since about 1999 when Microsoft introduced the XMLHTTPRequest object. If you aren't currently using it at all, then it would probably be good for you to find out about it, and see if it fits your need. I have some applications with very complex forms and I use the AJAX model to keep the users experience as clean as possible. The response time for retrieving the filtered lists are usually very fast and usually the users don't notice any delay at all. Compared to solution 1 (the full post back), the experience is superior in all ways. The only caveat is that Javascript must be enabled in the browser. This generally isn't a problem for your typical user, but some people shut off Javascript. Additionally, there are some browser compatibility issues that you have to work through.

You can search about on the web for AJAX and find numerous examples or tutorials. It is the way to go.

Here is the wiki entry on it: http://en.wikipedia.org/wiki/Ajax_%28programming%29

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic menus and content? gabster XSLT 6 October 16th, 2007 10:05 AM
How to dynamic display the content of the table? myhrvod Pro Java 0 August 3rd, 2006 12:42 AM
Dynamic content in Netscape not working. Help! nyc_courtney Javascript 2 August 25th, 2004 04:54 PM
HTM pages with dynamic content madhukp Classic ASP Basics 3 June 10th, 2004 03:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.