Thread: RE: Hide/show the option tag of select element
RE: Hide/show the option tag of select
element
United States
2008-05-07 11:50:06
Don't you want to set the attribute dynamically? It looks like it needs to happen either by hiding the option on the server by going through the ddl.Items and comparing it to some value, or in javascript based on a value in another control. Did you see the prior javascript I posted?
-Server
ddl.DataBind()
For each li in ddl.Items
if li.value = somevalue then
li.attributes.add("style","display:none")
Exit For
End If
Next -client
var ddl = document.forms[0].ddlBox
var items = ddl.options.length;
var blnGotIt = false;
var li = null;
for(i=0;i<items;i++)
{
if(ddl.options[i].value.toUpperCase() = someValue.toUpperCase())
{ li = ddl.options[i]
li.style.display = "none"; break;
} }
if(!blnGotIt)
{
if(li != null)
{ li.style.display = "block";
}
}
> Subject: [aspnet-databases] RE: Hide/show the option tag of select element > CC: aspnet-databasesaspadvice.com > From: Jayshree_Shahfpl.com > Date: Tue, 6 May 2008 07:24:13 -0700 > To: aspnet-databasesaspadvice.com > > I am trying to hide the option tag of select element based on the key > values from WEB config file > > I try simply with option's disable, display and visible attributes of style > but none of them works. > > Here is what I would like accomplish > > <select> > <option value = 1 style:display:none>option 1 > <option values = 2>option 2 > </select> > > Thanks in advance for all your help. > > > > |---------+----------------------------> > | | "Duane Lakoduk" | > | | <duanelakodukcom| > | | cast.net> | > | | | > | | 05/03/2008 07:35 | > | | PM | > | | Please respond to| > | | aspnet-databases | > | | | > |---------+----------------------------> > >------------------------------------------------------------------------------------------------------------------------------| > | | > | To: aspnet-databasesaspadvice.com | > | cc: | > | Subject: [aspnet-databases] RE: Hide/show the option tag of select element | > >------------------------------------------------------------------------------------------------------------------------------| > > > > > What are the conditions under which you want to Hide/show the option? > > If you are using a datasource for your DropDownList, you could just reload > your list and exclude the ListItem you want to hide. > > Send more details of what you are trying to accomplish. > > //Duane > > -----Original Message----- > From: Jayshree_Shahfpl.com [mailto:Jayshree_Shahfpl.com] > Sent: Thursday, May 01, 2008 12:40 PM > To: aspnet-databasesaspadvice.com > Cc: aspnet-databasesaspadvice.com > Subject: [aspnet-databases] Hide/show the option tag of select element > > All, > > How can I Hide/show the option tag of select element in ASP page? > > Thanks in advance for all your help. > > > > Need SQL Advice? http://sqladvice.com > Need RegEx Advice? http://regexadvice.com Need XML Advice? > http://xmladvice.com > > > > > Need SQL Advice? http://sqladvice.com > Need RegEx Advice? http://regexadvice.com > Need XML Advice? http://xmladvice.com > > > > > > > Need SQL Advice? http://sqladvice.com > Need RegEx Advice? http://regexadvice.com > Need XML Advice? http://xmladvice.com
Get Free (PRODUCT) RED™ Emoticons, Winks and Display Pics. Check it out!
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com