|
|||||||
| ASP Discussion and technical support for using and deploying Active Server Pages. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Display different lists
I am creating a page (See the following code) which includes a selection input and a product list. For different selection (1/2/3), the page presents different list. The default seleted value is 3, and default list is list_3.
When users change selection to 1 or 2, the page should display list_1 or list_2. Do you have any ideas about HOW TO do that? <form> <select size='1' name='myChoice'> <OPTION SELECTED>3</OPTION> <OPTION>2</OPTION> <OPTION>1</OPTION> </select> <% Dim thisLevel thisLevel = request.cookies("selectedNum") Select case thisLevel Case 3 myFile="../include/list_3.asp" Call DisplayFile(myFile) Case 2 myFile="../include/list_2.asp" Call DisplayFile(myFile) Case 1 myFile="../include/list_1.asp" Call DisplayFile(myFile) End Select %> </form> Thank you! Arguo |
|
#2
|
|||
|
|||
|
You should not have to store Cookies in order to achieve this..
Take a look at the code below.. HTML code: Code:
<form action="set_list.asp" method="get"> <select name="myChoice"> <option>1</option> <option>2</option> <option>3</option> </select> <input type="submit" name="submit" value="Submit form" /> </form> ASP code: (set_list.asp) Code:
<%
Option Explicit
dim the_list, myFile
the_list = request.queryString("myChoice")
select case CInt(the_list)
case 1
myFile = "list_1.asp"
case 2
myFile = "list_2.asp"
case 3
myFile = "list_3.asp"
case else
myFile = "list_1.asp"
end select
Call DisplayFile("../include/" & myFile) 'Call function.
%>
Andrew Buntine. |
|
#3
|
|||
|
|||
|
Thanks for your suggestion, which works well. However, I can't put a submit button between the SELECTION and LIST. Sorry, I didn't make it clear.
My page consists of an INPUT, a SELECTION, a Product List, and then a SUBMIT button. It's like this: <form> <input name="userID"> <select size='1' name='myChoice'> <OPTION SELECTED>3</OPTION> <OPTION>2</OPTION> <OPTION>1</OPTION> </select> <!-- display myFile here --> <input type="submit" name="submit" value="Submit form" /> </form> I got the default LIST displayed correctly, but couldn't get a specific LIST appeared after a user has selected information from the SELECTION. I think that I need some javascript onchange function. I already have an ASP sub, named DisplayFile(FileToRead). My problems are: 1. Can I use my javascript onchange functionthe together with this ASP sub? If possible, how the javascript onchange function call this ASP sub? 2. If NO, what the javascript onchange function should do? Again, thanks for your attention. Arguo |
|
#4
|
|||
|
|||
|
Hi,
I also tried this way (please see the following code). But it does not help me out. Any ideas? Thanks a lot! Arguo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <html> <head> <title>Select a product</title> <script language="JavaScript"> <!-- function getNum() { path = document.myForm; for (i=0 ; i< path.level.options.length ; i++ ) { if (path.level.options[i].selected) { myLevel = frm.level.options[i].text; return myLevel; break; } } } //==== function to SHOW or HIDE FormList function showList() { var changeV = getNum(); switch (changeV) { case 2: document.myForm.L1.style.dispaly='none'; document.myForm.L2.style.display='block'; document.myForm.L3.style.display='none'; break; case 1: document.myForm.L1.style.dispaly='block';"; document.myForm.L2.style.display='none';"; document.myForm.L3.style.display='none';"; break; default: document.myForm.L1.style.dispaly='none'; document.myForm.L2.style.display='none'; document.myForm.L3.style.display='block'; } } --> </script> </head> <body onLoad="showList()"> <form name='myForm' action="set_list.asp" method="get"> <select size='1' name='level' onChange="showList()"> <option selected>3</option> <option>2</option> <option>1</option> </select> <div name="L1"> <!-- #include file="../include/List_1.inc" --> </div> <div name="L2"> <!-- #include file="../include/List_2.inc" --> </div> <div name="L3"> <!-- #include file="../include/List_3.inc" --> </div> <input type="submit" name="submit" value="Submit form" /> </form> </body> </html> Last edited by Arguo; 02-04-2004 at 03:43 PM. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|