Results 1 to 3 of 3

Thread: Classic ASP Dropdown Lists and Default Values

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Location
    Scotland
    Posts
    68

    Classic ASP Dropdown Lists and Default Values

    Hello

    I am in the process of trying to create some Classic ASP web pages. The first page will allow the user to select data using a number of different criteria, some of them entered as text fields and others as selections in combo boxes (drop-down lists).

    Once the user has made his/her selection, s/he is taken to a second page which displays the results of the search.

    To be clear, the code for the first and second pages is sound: everything works exactly as I want it to. However, I'm looking at putting a link onto the second page that enables the user to return to the initial search screen and refine the search without having to re-enter all the criteria. I can get the first page displaying once more, and have started the job of re-populating all of the fields according to the values that were originally passed from page 1 to page 2.

    My problem is this: how do I assign an existing value to a combo box? When I repopulate the text fields, it's simply done using the value attribute for that field, and deciding whether the page is a new load or a reload from the second page. However when I try to do this using a combo box I get told that the value attribute is not valid for a select element.

    Can someone tell me how I get around this issue?

    Thanks

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Classic ASP Dropdown Lists and Default Values

    Here are 2 very simple asp pages that may give you some ideas.

    Page 1
    Code:
    <html>
    <head><title>Main Page</title>
    </head>
    <body>
    	<&#37;
    		Dim color		
    		color = Request.QueryString("color")
    	%>
    	
    	<form id="frm" action="page2.asp" method="post">
    		<select id="color" name="color">
    			<option value="">-- Select a color --</option>
    			<option value="Red" <% If color = "Red" Then Response.Write(" selected")%>>Red</option>
    			<option value="Green" <% If color = "Green" Then Response.Write(" selected")%>>Green</option>
    			<option value="Blue" <% If color = "Blue" Then Response.Write(" selected")%>>Blue</option>
    		</select>
    		<input type="submit" id="submit" value="Submit" />	
    	</form>
    </body>
    </html>
    Page 2
    Code:
    <html>
    <head><title>Page 2</title>
    </head>
    <body>
    	<%
    		Dim color		
    		color = Request.Form("color")
    	%>
    	
    	Your selected color is <%=color%> <br />
    	<a href="page1.asp?color=<%=color%>">Return to the main page</a>
    </body>
    </html>

  3. #3
    New Member jmarkg11's Avatar
    Join Date
    Jul 2013
    Posts
    1

    Re: Classic ASP Dropdown Lists and Default Values

    Markt

    Thats right script,!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width