www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > ASP

    ASP Discussion and technical support for using and deploying Active Server Pages.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 02-04-2004, 09:46 AM
    Arguo Arguo is offline
    Registered User
     
    Join Date: Feb 2004
    Posts: 31
    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
    Reply With Quote
      #2  
    Old 02-04-2004, 10:59 AM
    buntine buntine is offline
    Super Moderator
     
    Join Date: Jan 2004
    Location: Melbourne, Australia
    Posts: 5,527
    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>
    Then we process the contents of the form and set the correct list depending on the option selected in the <select> box.

    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.
    %>
    Regards,
    Andrew Buntine.
    Reply With Quote
      #3  
    Old 02-04-2004, 12:39 PM
    Arguo Arguo is offline
    Registered User
     
    Join Date: Feb 2004
    Posts: 31
    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
    Reply With Quote
      #4  
    Old 02-04-2004, 03:40 PM
    Arguo Arguo is offline
    Registered User
     
    Join Date: Feb 2004
    Posts: 31
    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.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:46 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.