Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Drop Downs

  Asked By: Hayfa    Date: May 01    Category: Asp.net    Views: 650
  

I have three drop downs on my date.aspx page, ddMonthOne , ddMonthTwo and
ddMonthThree, all three drop downs are populated by the same query from the
same database and from the same table, they all have the months of the year
as selections.



What I would like to do without a post back preferably but if post back is
the only way its ok... is if January (or any other month jan is an example)
is selected ddMonthOne, then January(or which ever month was selected) is
not available in ddMonthTwo and ddMonthThree

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Adalia Fischer     Answered On: May 01

you could do this with client-side javascript functions. In your
aspx definition - for each dropdownlist -- add the attribute


onChange="javascript:DeleteFromOtherLists(this.id);"

Then in the HEAD of your aspx, define a javascript function..

<HEAD>
<script language="javascript">
function DeleteFromOtherLists(sSelectedID) {

}
</script>
</HEAD>
...


In your javascript function, determine which drop-down ID is calling the
function & run a loop on the other drop  downs - looking for


document.getElementById("otherDropDownList").options[document.getElementById
("otherDropDownList").selectedIndex] ==

document.getElementById(sSelectedID).options[document.getElementById(sSelect
edID).selectedIndex]

If it's equal - you can set the other dropDownList's option to null - and
that will take it out of the drop down list...


document.getElementById("otherDropDownList").options[document.getElementById
("otherDropDownList").selectedIndex] = null;

 
Didn't find what you were looking for? Find more on Drop Downs Or get search suggestion and latest updates.




Tagged: