Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remove duplicate from dropdown list when it is the current data field.

Posted on 2010-08-19
5
Medium Priority
?
507 Views
Last Modified: 2012-05-10
I have a dropdown box with 3 selections in it. I placed some code to dynamically show from the database the current field it is set to however it is duplicated with my static choices. is there a way to keep the static selection but not have duplication?

Thanks in advance.
0
Comment
Question by:colonelblue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 33482045
Post ur code . please !
0
 
LVL 22

Expert Comment

by:Om Prakash
ID: 33482283
If you are using classic asp then you can compare static values in database if they do not match then display the data...


<select>
<%
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
do until rs.EOF
    if not rs("fieldname") = "staticfield" then  
       'add the option in select box..
    end if
    rs.MoveNext
loop
%>
--you can add static option here..
</Select>

Open in new window

0
 

Author Comment

by:colonelblue
ID: 33486649
Hello and thank you. I am not certain how to incorporate that code, especially, the ", conn" part.

Here is my code.

Thank s in advance experts.

<select  name="Header" id="Header">
          <option value="<%=((Recordset1.Fields.Item("Page_Header").Value))%>" selected="selected"><%=((Recordset1.Fields.Item("Page_Header").Value))%></option>
          <option value="Maintenance Notice">Maintenance Notice</option>
          <option value="Systems Down">Systems Down</option>
          <option value="All Systems Go">All Systems Go</option>
        </select>

Open in new window

0
 

Author Comment

by:colonelblue
ID: 33486673
And to add what I would get as a result shown in dropbox from the above is:

All Systems Go
Maintenance Notice
Systems Down
All Systems Go

The currently selected stuts from the database is "All Systems Go"
But it is repeated.
0
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 33491550
try this .
<%
static_value = split("Maintenance Notice,System Down,All Systems Go",",")
sql = "select Page_Header from tbl"  ' Adjust ur query 
set dr = con.execute(sql)
dim chk_duplicate
chk_duplicate = false
%>

<select distinct name="Header" id="Header">
         
           <% for each static_ind in static_value%>
          <option value="<%=static_ind%>"><%=static_ind%></option>
           <%next%>
          <%
		  while not dr.eof 
		     for each static_ind in static_value
			     if  trim(static_ind) = trim(dr(0)) then 
				    chk_duplicate = true
				 end if 	
			next
			 if chk_duplicate = false then %>
			  <option value="<%=dr(0)%>"><%=dr(0)%></option>
			<% end if 
			 dr.movenext 
			 chk_duplicate = false   'Again setting the status
		  wend 	 
		  %>
          
</select>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question