I have a select box call 'ToLB' which takes in value items from another select box. I need to extract those selected values from 'ToLB' and print it on a label, this is how I do it but apparently it's not working as in no error message but nothing was printed to the label, please kindly advice, thanks! :
The Select box:
<select multiple size="8" name="ToLB" style="width: 135px" onblur="javascript:dropValue6(this)">
</select>
The label:
QMType: <asp:Label ID="destinationQualMemType" runat="server" ></asp:Label >
Javascript function:
function dropValue6(source) {
while (source.selectedIndex != -1)
{
if (source.selectedIndex != 0) arSelected.push(source.options[source.selectedIndex].value);
source.options[source.selectedIndex].selected = false;
var i;
for (i = 0; i < arSelected; i++) {
document.getElementById('<%= destinationSpendingType.ClientID %&g开发者_开发知识库t;').innerHTML =
+ "\n" + document.getElementById('<%= destinationSpendingType.ClientID %>').innerHTML = arSelected[i].value;
}
}
}
You might look at the lines marked //***
function dropValue6(source) {
var arSelected = []; // ***
while (source.selectedIndex != -1)
{
if (source.selectedIndex != 0) arSelected.push(source.options[source.selectedIndex].value);
source.options[source.selectedIndex].selected = false;
var i;
for (i = 0; i < arSelected.length; i++) { // ***
document.getElementById('<%= destinationSpendingType.ClientID %>').innerHTML = arSelected[i]; // ***
}
}
}
精彩评论