5
rated 0 times
[
12]
[
7]
/ answers: 1 / hits: 24725
/ 13 Years ago, fri, october 14, 2011, 12:00:00
In my apsx page, I have a listbox (techGroups) that has some items that are preselected. The user can change the selections. Meanwhile, I have a reset button. When the user click the reset button, the listbox will be restored with those preselected items selected, while others are not.
I write following javascript function for the reset button's onclientclick. Somehow, after i click the reset button, only the first preselected item get selected, all other preselected items are not.
reset()
{
var selectedGroups = hiddenfield1.value.split(,); //i saved those preselected items in a hiddenfield
for (var i = 0; i < techGroups.options.length; i++) {
for (var j = 0; j < selectedGroups.length; j++) {
if (techGroups.options[i].value == selectedGroups[j]) {
techGroups.options[i].selected = true;
}
}
}
}
Can anybody help me to look at my code and tell me what is wrong? Thanks.
More From » asp.net