|
-
May 23rd, 2012, 04:34 AM
#1
Thread Starter
Lively Member
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
-
May 26th, 2012, 09:52 AM
#2
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>
<%
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>
-
Jul 16th, 2013, 03:36 AM
#3
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|