473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

asp dropdown list with a condition

229 100+
Hi, Would anyone know how to populate an asp dropdown with a dependant condition.

I need this dropdown to select only artists, ie from the authortwo field where in another field, ie extrathree, the word yes is written.



Expand|Select|Wrap|Line Numbers
  1.   <form method="Post">
  2.       <div>
  3. <select onChange="window.location='' + this.options[this.selectedIndex].value">
  4. <OPTION VALUE = 'artists'>&nbsp;artists</Option>
  5. <OPTION>-----------------------------------------------------</Option>
  6. <%        
  7.     Set oRs=Server.CreateObject("adodb.recordset")
  8.     strSQL = "SELECT DISTINCT AuthorTwo FROM tblGreetingPostCards ORDER BY AuthorTwo"
  9.     oRs.Open strSQL, conn        
  10.  
  11.     Do while not oRs.EOF
  12.         if Request.Form("GreetingPostCards") = oRs("AuthorTwo") then 'if this is the selected one then display as selected
  13.             Response.Write "<OPTION VALUE = '" & oRS ("AuthorTwo") & "' SELECTED>"
  14.             Response.Write oRs("AuthorTwo") & "</Option>"
  15.             oRs.MoveNext 
  16.     else
  17.             Response.Write "<OPTION VALUE = 'http://www.mysite.com/artgallery.asp?AuthorTwo=" & oRs ("AuthorTwo") & "'>&nbsp;"
  18.             Response.Write oRs("AuthorTwo") & "</Option>"
  19.             oRs.MoveNext 
  20.         end if
  21.     loop        
  22.     %>
  23. </SELECT>
  24. </div>
  25.   </form>
somehow to combine another condition like


Expand|Select|Wrap|Line Numbers
  1.                                     <%
  2. If InStr(rsCard("extrathree"),"yes") > 0 Then
  3. %>
  4.  
  5.  
  6.  
  7. <I><a href="portfol.asp?authortwo=<%=rsCard("authortwo")%>" title="">info&nbsp;</I><a>
  8. <%
  9. Else
  10. %>
  11.  
  12. <%
  13. End If
  14. %>  
Any help would be great.
Thanks in advance

Richard
Feb 9 '08 #1
6 2370
CroCrew
564 Expert 512MB
Hello fran7,

I am having a hard time understanding what you are trying to do. I really would like to help you out. Can you give a better example on what you are trying to accomplish? The more detail you can provide in this case is better. No need for posting anymore code just what you wish to accomplish in detail.

Here is a stab at trying to answer your questing with what I have read above.

Why don’t you just extend your SQL syntax to add in the condition of the field “extrathree” equaling the word “yes” like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT AuthorTwo FROM tblGreetingPostCards WHERE extrathree = ‘yes’ ORDER BY AuthorTwo
  2.  
Feb 11 '08 #2
markrawlingson
346 Expert 100+
Also Richard, this really has nothing to do with your question, just a helpful observation. I see that you are trying to categorize things within your drop down like so...

Expand|Select|Wrap|Line Numbers
  1. <OPTION VALUE = 'artists'>&nbsp;artists</Option>
  2. <OPTION>-----------------------------------------------------</Option>
  3.  
Google <OPTGROUP>

EG:
Expand|Select|Wrap|Line Numbers
  1. <select>
  2.    <optgroup label="Artists">
  3.       <option value="Artist1">Artist 1</option>
  4.       <option value="Artist2">Artist 2</option>
  5.       <option value="Artist3">Artist 3</option>
  6.    </optgroup>
  7.  
http://www.w3schools.com/tags/tag_optgroup.asp

Sincerely,
Mark
Feb 11 '08 #3
fran7
229 100+
Dear Mark, Thanks for the reply.

I hope I can explain better. Basically the dropdown list I have above works fine. But I need it to be populated only by the artists who have " yes" written in another field called "extrathree".

Summary
I have a field called authortwo with all my artists names.
I have another field extrathree where selective artists have a "yes" written. Those without the "yes" at the moment are left blank but I could fill them with "no" for example.

So the problem is to populate the dropdown with only those artists names with "yes" written in the field "extrathree"

Any help would be great.
Thanks
Richard
Feb 12 '08 #4
DrBunchman
979 Expert 512MB
Hi Richard,

I think CroCrew already answered your question didn't he? If you change your SQL string to:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT DISTINCT AuthorTwo FROM tblGreetingPostCards WHERE extrathree = 'yes' ORDER BY AuthorTwo"
Then only the authors with yes next to their name in the column extrathree will be selected and included in your drop down.

Or is it something else you are after?

Let us know,

Dr B
Feb 12 '08 #5
markrawlingson
346 Expert 100+
Yes, CroCrew answered your question accurately fran7 - I was merely making a non-related observation ;)

Sincerely,
Mark
Feb 12 '08 #6
fran7
229 100+
Dear Mark, I did try that before and it didnt work. must have made a typo. I tried again and bobs your uncle. Works great. Thanks again
Richard
Feb 12 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
3
by: er1 | last post by:
Hi all, I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query...
3
by: quark1 | last post by:
How do I set the value of ProdQuality_1_hid and change the drop down list on the screeen? I tried sending to the address bar: javascript:setProdQuality_1_hid('Medium') {enter} but I...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
2
by: JJ297 | last post by:
I have a dropdown list populated via a database. I edited the dropdown list to have "select a topic" to always appear when the drop down loads. Now if a user selects a dropdown item it goes into...
3
by: fish919 | last post by:
Hello All, I am creating a date base in access. I want to create a dropdown list box that is connected to another dropdown list box. You start with a dropdown list that has 5 choices and each of...
5
by: abhi3211 | last post by:
i am using java inside java script page. in that page i want to use two dropdown list. in first dropdown list i am getting data from ms-access database. in second dropdown list i want to get data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.