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

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.
Who is Participating?
Rajar AhmedConnect With a Mentor ConsultantCommented:
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>
		  while not dr.eof 
		     for each static_ind in static_value
			     if  trim(static_ind) = trim(dr(0)) then 
				    chk_duplicate = true
				 end if 	
			 if chk_duplicate = false then %>
			  <option value="<%=dr(0)%>"><%=dr(0)%></option>
			<% end if 
			 chk_duplicate = false   'Again setting the status

Open in new window

Rajar AhmedConsultantCommented:
Post ur code . please !
Om PrakashCommented:
If you are using classic asp then you can compare static values in database if they do not match then display the data...

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
--you can add static option here..

Open in new window

colonelblueAuthor Commented:
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>

Open in new window

colonelblueAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.