2012年3月28日水曜日

Reset Cascading Dropdown

I have a set of cascading dropdowns that I need to be able to programatically reset via javascript. I can change the selectedIndexes but that doesn't change any of the data "behind the scenes".

Thanks

Hi

Doesn't change any of the data "behind the scenes", What you mean?

Would you please post some code,so I can reproduce the problem and resolve it more quickly?

Thanks


As I have seen it for three cascading drop downs there are also three hidden form fields that contain data. My specific scenario was modifing some existing code that utilized three drop downs. The application was a store selector. The user could type in a postal code or use drop downs (Country, Region, City). I needed to reset the drop downs if a user types in a postal code. Setting up the blur event on the postal code text box was simple enough. But getting the drop-downs to reset was more challenging. I originally trimmed the item list down to the first item (please select). However on postback the original drop down selections came back. What I ended up doing was triming the item list and resetting the "hidden" fields to ":::" which is what the starting state appears to be.

There has to be an easier way to reset the drop downs to thier default state (via javascript). If the user simply sets the first drop down to the 0 index all drop downs reset. However, using using JS to set the selectedIndex property doesn't cause the client side event to fire.

Hopefully that helps a little. I am probably just missing something obvious. Is the client side JS code documented anywhere?

0 件のコメント:

コメントを投稿