Dynamically clear selected items of itembox
-
How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?
Size
5" 6" 7" 8" 9"
Color
Red Green Blue Yellow
Thanks
-
How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?
Size
5" 6" 7" 8" 9"
Color
Red Green Blue Yellow
Thanks
-
How would I add code to the htm below to clear the selected items of one listbox when the focus is put on another listbox? Would I use javascript?
Size
5" 6" 7" 8" 9"
Color
Red Green Blue Yellow
Thanks
Hi Dlugie Try below functions for listbox and submit button The submit button function is written to allow you to check the last focused listbox and it will not remove the selected items text1 is a hidden textbox. Also, plz use id for list boxes or any control you place in your form. What i have seen is that id is much helpful in getting the element than by name. check these corrections: addition: ----------your functions-------------- function lbonfocusout(lb) { if(myform.text1.value=="1") return; myform.all(lb.id).selectedIndex=-1 } function Submit_onbeforeactivate() { myform.text1.value="1"; for(x=0;x
-
Hi Dlugie Try below functions for listbox and submit button The submit button function is written to allow you to check the last focused listbox and it will not remove the selected items text1 is a hidden textbox. Also, plz use id for list boxes or any control you place in your form. What i have seen is that id is much helpful in getting the element than by name. check these corrections: addition: ----------your functions-------------- function lbonfocusout(lb) { if(myform.text1.value=="1") return; myform.all(lb.id).selectedIndex=-1 } function Submit_onbeforeactivate() { myform.text1.value="1"; for(x=0;x
Thanks for the replies. Maybe I’m not explaining the problem correctly. I have two itemboxes and two radio buttons. I want to clear the selected items (not delete) from the one itembox when focus is set on the other itembox. I was able to partially achieve this with the code below but was not able to completely clear the selected items. P.S --> I'm new to javascript so thanks for your patience and help :) -------------------------------------------------------------- function lbOnFocus(field) { switch (field){ case "lbSize": if (document.myform.rbCriteria[0].checked = true) { document.myform.rbCriteria[1].checked = true; document.myform.lbSize.selectedIndex = null; } else { document.myform.rbCriteria[0].checked = true; } break; case "lbColor": if (document.myform.rbCriteria[1].checked = true) { document.myform.rbCriteria[0].checked = true; document.myform.lbColor.selectedIndex = null; } else { document.myform.rbCriteria[1].checked = true; } break; } } --------------------------------------------------------------
-
Thanks for the replies. Maybe I’m not explaining the problem correctly. I have two itemboxes and two radio buttons. I want to clear the selected items (not delete) from the one itembox when focus is set on the other itembox. I was able to partially achieve this with the code below but was not able to completely clear the selected items. P.S --> I'm new to javascript so thanks for your patience and help :) -------------------------------------------------------------- function lbOnFocus(field) { switch (field){ case "lbSize": if (document.myform.rbCriteria[0].checked = true) { document.myform.rbCriteria[1].checked = true; document.myform.lbSize.selectedIndex = null; } else { document.myform.rbCriteria[0].checked = true; } break; case "lbColor": if (document.myform.rbCriteria[1].checked = true) { document.myform.rbCriteria[0].checked = true; document.myform.lbColor.selectedIndex = null; } else { document.myform.rbCriteria[1].checked = true; } break; } } --------------------------------------------------------------
This is why i'm a novice ;P The following lines: document.myform.lbSize.selectedIndex = null; document.myform.lbColor.selectedIndex = null; should be replaced with: document.myform.lbSize.selectedIndex = -1; document.myform.lbColor.selectedIndex = -1; Thanks for your help..