Hi everybody

I use a javascript to select and deselect items in a listbox depending on checkbox selection

The problem now i have is, i am calling the javascript from server side

What happens is as the listbox 1 get populated, and selected with checkbox selection in my application,
i have a button which refreshes the page thereby populating listbox2, with reference to the items selected in listbox1

So what is happening is,
- the user selects checkall-- all items get selected
- the user hits the refresh button -- all the items deselected and also checkbox is marked unchecked

Hope you can understand my issue
Please help me to fix this dilemma
Thanks to all

The application that your working on.. is it a web application? and i really can't understand what the error is.. May be you can post some code and explain it with a screen shot.

Thanks for your response
it is a web application
The code i am using is

function onChange(checkBoxRef,listboxId)
{

var listboxRef = document.getElementById(listboxId)

if(checkBoxRef.checked)
{


for (var i=0;i<listboxRef.options.length;i++)


{

listboxRef.options[i].selected = true;

}
}
else
{

for (var i=0; i<listboxRef.options.length; i++)

{

listboxRef.options[i].selected = false;

}
}
}

function removeCheck(checkboxId)
{
document.getElementById(checkboxId).checked = false;
}

And in code behind i am using

lstAccounts.Attributes.Add("onChange", "Javascript:removeCheck('" + chkAll.ClientID + "');")
chkAll.Attributes.Add("onClick", "javascript:onChange(this, '" + lstAccounts.ClientID + "');")

When the page is refreshed by a button click, all the items are deselcted and the checkbox mark is also gone
Any ideas, what is wrong with my code?

Thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.