Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional 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 August 31st, 2007, 09:01 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default combo box remain selected after submission



Hello to everyone !!!!!!
I have newly joined this forum.

I have a problem.If anbody can? Please help...

The thing is I have an asp page having one select box.When i select it It's selected value is displayed on the same page but the combobox does not retain in the same selected position.could it be done by any means.

---THE CODE---
<html>
<head><title>dpd</title>

</head>
<body>

<%
dim str
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
dim country
country = split(str," ")
dim c
c=ubound(country)

response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
for i=0 to c
  response.write("<option value="&country(i)&">"+Cstr(country(i)))
  response.write("</option>")
next
response.write("</select></form>")
%>
<%t=request.form("cbo")%>
<%=t%>

</body>
</html>

---END---

One thing more:The asp page will generate this in an html format.That is I can see the view source.
Thanksssssss in advance !!!!!

RKB
 
Old September 4th, 2007, 01:18 PM
Authorized User
 
Join Date: Sep 2007
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have modified your code...I just added a function that inside your loop of values in the dropdown checks the current value to see if they match...if so I return the html property selected to the option tag....see below

---------------------------------------

<html>
<head><title>dpd</title>

</head>
<body>

<%
dim str
str = "select india pakistan bangladesh usa uk china indonesia southAfrica"
dim country
country = split(str," ")
dim c
c=ubound(country)

response.write("<form id=frm action=dpd.asp method=post><select name=cbo onchange=frm.submit()>")
for i=0 to c
  isSelected = selected(request("cbo"),country(i))
  response.write("<option value="&country(i)&" " & isSelected & ">"+Cstr(country(i)))
  response.write("</option>")
next


response.write("</select></form>")
%>
<%t=request.form("cbo")%>
<%=t%>


<%
    function selected(current,valueCheck)
        if lcase(current) = lcase(valueCheck) then
            selected = "selected=selected"
        else
            selected = ""
        end if
    end function
%>
</body>
</html>


http://mynameissteve.com
 
Old September 7th, 2007, 07:56 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am very very sorry sdi126
I was in a leave for 2 days.
Hence I am lately responding to your answer.

your code works fine !!!!!!!!

I am Sooooooooooooooory again

RKB





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Can't get the selected value of a combo... gbianchi ASP.NET 1.0 and 1.1 Basics 7 March 3rd, 2006 02:48 PM
How to Update Selected Item in Combo after Postbac ZArrinPour ASP.NET 1.0 and 1.1 Basics 2 February 21st, 2006 02:17 AM





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