Click to See Complete Forum and Search --> : Please help with disappearing listbox items


Vengeance
02-10-2004, 10:55 AM
Hi everyone,

I recently posted this in the Javascript forum. But after thinking about it I thought that this would be another, if not better, forum to ask it.

On the parent_form.aspx I have these controls

<asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox>
<INPUT class="loButton" onclick="java script:getOptionPicker('?mid=TS5&callingcontrol=Operators');" type="button" value="+">
<asp:button id="save" runat="server" CssClass="loButton" Text="Save"></asp:button>

I also use a global.js file which adds the following functions

function getOptionPicker(extras)
{
var features;
features = " status=no,scrollBars=no,resizable=no,toolbar=no,me
nubar=no,location=no,directories=no,width=300,heig
ht=200";
var option_window;
option_window = window.open("option_picker.aspx" + extras, "Add_Options", features);
option_window.focus();
}

function addToParentList(sourceList, destinationList)
{
destinationList = document.getElementById(destinationList);
for(var count = destinationList.options.length - 1; count >= 0; count--)
{
destinationList.options[count] = null;
}
for(var i = 0; i < sourceList.options.length; i++)
{
if (sourceList.options[i] != null)
{destinationList.options[i] = new Option(sourceList.options[i].text, sourceList.options[i].value);}
}
}



On the option_picker.aspx form I have these controls and functions

<asp:listbox id="destList" runat="server" SelectionMode="Multiple" Width="100px" Height="134px" AutoPostBack="True"></asp:listbox>
<input id="Done" onclick="java script:addSelectedItemsToParent()" type="button" value="Done" name="Done">

function addSelectedItemsToParent()
{
self.opener.addToParentList(window.document.forms[0].destList, window.document.forms[0].CallingControl.value);
window.close();
}



So, when the user clicks the INPUT button on the parent_form getOptionPicker() is called which opens the option_picker form.
From there they do what they need and get a list of items in the destList asp:listbox and click the Done INPUT button.
This calls the local addSelectedItemsToParent() which in turn calls the addToParentList() from the global.js file which was included on the parent form.
The Operators asp:listbox is correctly filled with the contents from the child form.
The user then clicks the Save asp:button to store their information.
However, by time any code can be executed in that button's click event, the listbox reads as being empty.

I am at a total loss as to why this is happening. I have similar code that deals with setting the value of a textbox and this works perfectly.

I have seen a few other people trying to do the same thing and from what I gather they are running into the same kind of problem. But no one ever replies with a solution.

Any help would be greatly appreciated.

Brian