I. I am working on a project to prevent page refreshing and use dropdownlist to control the content of ListBox.
The Code is as follows:
- Function deletemethod ()
- {
- VaR objselect = Document. getelementbyid ('listbox1 ');
- If (objselect. selectedindex! =-1)
- {
- Objselect. Remove (objselect. selectedindex );
- }
- If (document. getelementbyid ('listbox1'). Options. Length <3)
- {
- Document. getelementbyid ('slt _ person'). Disabled = false;
- }
- }
- Function checkstate ()
- {
- If (document. getelementbyid ('listbox1'). Options. Length = 0)
- {
- Document. All. Remove. Disabled = true;
- }
- Else
- {
- Document. All. Remove. Disabled = false;
- }
- If (document. getelementbyid ('listbox1'). Options. Length = 3)
- {
- Document. getelementbyid ('slt _ person'). Disabled = true;
- }
- }
- Function additem ()
- {
- VaR text = Document. All. slt_person.options [document. All. slt_person.selectedindex]. text;
- VaR values = Document. All. slt_person.options [document. All. slt_person.selectedindex]. value;
- VaR list = Document. getelementbyid ('listbox1 ');
- If (values! = '-1 '&&! Isexist (values, list ))
- {
- List. Options. Add (New Option (text, values, values, 0 ));
- }
- }
- Function isexist (SS, LL)
- {
- VaR length = Document. getelementbyid ('listbox1'). Options. length;
- For (VAR I = 0; I <length; I ++)
- {
- If (LL. Options [I]. value = SS)
- Return true
- }
- Return false;
- }
2. listbox1 binds the database content, and then binds the script to the event on the corresponding control.